代码:
public static void DoEvents(Dispatcher dispatcher) { DispatcherFrame frame = new DispatcherFrame(); dispatcher.BeginInvoke(new Action<object>((obj) => { DispatcherFrame frm = obj as DispatcherFrame; frm.Continue = false; }), DispatcherPriority.Background, frame); Dispatcher.PushFrame(frame); }