1
为什么下面的代码(.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 { }));
}
编辑
SLaks此言后更新版本
public static void DoEvents(this Application a)
{
if (a != null)
{
a.Dispatcher.Invoke(
System.Windows.Threading.DispatcherPriority.Background,
new Action(delegate { }));
}
}
你为什么不使用你的参数? – SLaks 2010-12-21 17:59:49
你想完成什么? – mcabral 2010-12-21 18:09:18