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();

posted @ 2017-12-13 11:10  willamyao  阅读(302)  评论(0编辑  收藏  举报