Is there a synchronous wait function that won\'t tie up the UI-thread in .NET WPF? Something like:
Sub OnClick(sender As Object, e As MouseEventArgs) Handle
You can use a DispatcherTimer for that sort of thing.
Edit: This might do as well...
private void Wait(double seconds)
{
var frame = new DispatcherFrame();
new Thread((ThreadStart)(() =>
{
Thread.Sleep(TimeSpan.FromSeconds(seconds));
frame.Continue = false;
})).Start();
Dispatcher.PushFrame(frame);
}
(Dispatcher.PushFrame documentation.)
Starting with .NET 4.5 you can use async event handlers and Task.Delay to get the same behaviour. To simply let the UI update during such a handler return Dispatcher.Yield.