代码:
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); }
如何使用:
this.Dispatcher.BeginInvoke(new Action(() => { while (true) { double dd = Math.PI * Math.PI; ThreadHelper.DoEvents(this.Dispatcher); } }));