这里是MSDN提供的代码,虽然它似乎并不清楚它在做什么:
[SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
public void DoEvents()
{
DispatcherFrame frame = new DispatcherFrame();
Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background,
new DispatcherOperationCallback(ExitFrame), frame);
Dispatcher.PushFrame(frame);
}
public object ExitFrame(object f)
{
((DispatcherFrame)f).Continue = false;
return null;
}
我刚刚在一些遗留代码中发现了类似的实现,其中定义了DoEvents
方法。为什么我们需要这个以及将帧推送到调度程序意味着什么?