WPF实现DoEvents

WPF实现DoEvents

原创 2011年06月30日 12:23:00
[c-sharp] view plain copy
 
  1. static void DoEvents()  
  2.         {  
  3.             DispatcherFrame frame = new DispatcherFrame(true);  
  4.             Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, (SendOrPostCallback)delegate(object arg)  
  5.             {  
  6.                 DispatcherFrame fr = arg as DispatcherFrame;  
  7.                 fr.Continue = false;  
  8.             }, frame);  
  9.             Dispatcher.PushFrame(frame);  
  10.         }  

调用:

DoEvents();

原文地址:https://www.cnblogs.com/robertyao/p/8031876.html