Blame view

OS.Spin/OS.Spin.View/Utils/App.cs 1.37 KB
8ca6e89d   Tuo Wenbo   20211021
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
  using OS.Spin.Common;
  using System;
  using System.Windows;
  using System.Windows.Threading;
  
  namespace OS.Spin.View.Utils
  {
      public partial class App : Application
      {
          private static DispatcherOperationCallback exitFrameCallback = new DispatcherOperationCallback(ExitFrame);
          public static void DoEvents()
          {
              try
              {
                  DispatcherFrame nestedFrame = new DispatcherFrame();
                  DispatcherOperation exitOperation = Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, exitFrameCallback, nestedFrame);
                  Dispatcher.PushFrame(nestedFrame);
                  if (exitOperation.Status !=
                  DispatcherOperationStatus.Completed)
                  {
                      exitOperation.Abort();
                  }
              }
              catch (Exception ex)
              {
                  LogisTrac.WriteLog(string.Format("DoEvents:{0}", ex.Message));
              }
          }
  
          private static Object ExitFrame(Object state)
          {
              try
              {
                  DispatcherFrame frame = state as
                      DispatcherFrame;
                  frame.Continue = false;
              }
              catch (Exception ex)
              {
                  LogisTrac.WriteLog(string.Format("ExitFrame:{0}", ex.Message));
              }
              return null;
          }
  
      }
  }