类似System.Windows.Forms.Application.DoEvents 处理当前在消息队列中的所有消息
private static readonly DispatcherOperationCallback _exit_frame_callback = (state)=>{
var frame = state as DispatcherFrame;
if( null == frame )
throw;
frame.Continue = false;
return null;
};
public static void DoEvents(){
var frame = new DispatcherFrame();
var exOperation = Dispatcher.CurrentDispatcher.BeginInvoke(
DispatcherPriority.Background,_exit_frame_callback ,
frame
);
Dispatcher.PushFrame( frame );
if( exOperation .Status != DispatcherOperationStatus.Completed){
exOperation.Abort();
}
}
Created 2013.08.04 / Andy