Code 1/**//// <summary> 2 /// App.xaml 的交互逻辑 3 /// </summary> 4 public partial class App : Application 5 { 6 private static DispatcherOperationCallback exitFrameCallback = new DispatcherOperationCallback(ExitFrame); 7 8 public static void DoEvents() 9 {10 DispatcherFrame nestedFrame = new DispatcherFrame();1112 DispatcherOperation exitOperation = Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, exitFrameCallback, nestedFrame);1314 Dispatcher.PushFrame(nestedFrame);1516 if (exitOperation.Status != DispatcherOperationStatus.Completed)17 {18 exitOperation.Abort();19 }20 }2122 private static Object ExitFrame(Object state)23 {24 DispatcherFrame frame = state as DispatcherFrame;25 frame.Continue = false;26 return null;27 }28 } 转载于:https://www.cnblogs.com/xsi640/articles/1593219.html