Beispiel #1
0
 public static void WaitFor(IAsyncResult async)
 {
     if (async.IsCompleted)
     {
         return;
     }
     if (AsyncTool.IsMainThread)
     {
         WaitObject.ActiveWait(async);
     }
     else
     {
         if (async.AsyncWaitHandle != null)
         {
             async.AsyncWaitHandle.WaitOne();
         }
         else
         {
             while (!async.IsCompleted)
             {
                 Thread.Sleep(100);
             }
         }
     }
 }
Beispiel #2
0
 public WaitContext()
 {
     if (!AsyncTool.IsMainThread)
     {
         return;
     }
     WaitObject.EnterContext();
 }
Beispiel #3
0
 public static void EnterContext()
 {
     if (Instance == null)
     {
         Instance = new WaitObject();
     }
     Instance.m_contextDepth++;
 }
Beispiel #4
0
 public void Dispose()
 {
     if (!AsyncTool.IsMainThread)
     {
         return;
     }
     WaitObject.LeaveContext();
 }
Beispiel #5
0
 public static void LeaveContext()
 {
     Instance.m_contextDepth--;
     if (Instance.m_contextDepth == 0)
     {
         Instance.Close();
         Instance = null;
     }
 }