Why the code bellow (.NET-4, Extension method) does not leave me using Application.DoEvents();
?
/// <summary>
/// Invokes in the Dispatcher an empty action.
/// An thread safe equivalent of the ancient Application.DoEvents.
/// </summary>
public static void DoEvents(this Application a)
{
Application.Current.Dispatcher.Invoke(
System.Windows.Threading.DispatcherPriority.Background,
new Action(delegate { }));
}
EDIT
updated version after SLaks remark
public static void DoEvents(this Application a)
{
if (a != null)
{
a.Dispatcher.Invoke(
System.Windows.Threading.DispatcherPriority.Background,
new Action(delegate { }));
}
}