Почему код ниже (.NET-4, метод расширения) не оставляет меня, используя 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
обновленная версия после замечания SLaks
public static void DoEvents(this Application a)
{
if (a != null)
{
a.Dispatcher.Invoke(
System.Windows.Threading.DispatcherPriority.Background,
new Action(delegate { }));
}
}