In WPF due to the intricacies on how the interface is updated I sometimes have to perform actions after a short delay.
Currently I'm doing this simply by:
var dt = new DispatcherTimer(DispatcherPriority.Send);
dt.Tick += (s, e) =>
{
dt.Stop();
//DoStuff
};
dt.Interval = TimeSpan.FromMilliseconds(200);
dt.Start();
But it's both a bit ugly and perhaps too much overhead to create a new timer each time (?) What's the best from a performance standpoint to do it, ie execute most promptly? And what's good way to rewrite the above code into something like:
this.Dispatcher.BeginInvoke(new Action(delegate()
{
//DoStuff
}), DispatcherPriority.Send,TimeSpan.FromMilliseconds(200));
Where Timespan is the delay, Thanks for any input :)