WPF - DispatcherHelper

来源:互联网 发布:cda数据分析师考试条件 编辑:程序博客网 时间:2024/06/05 11:42

类似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

原创粉丝点击