Пример #1
0
 // AttemptToTerminateServer() will check to see if the objects count and the server
 // lock count have both dropped to zero.
 //
 // If so, and if we were started by COM, we post a WM_QUIT message to the main thread's
 // message loop. This will cause the message loop to exit and hence the termination
 // of this application. If hand-started, then just trace that it WOULD exit now.
 //
 public static void ExitIf()
 {
     lock (lockObject)
     {
         OCSimulator.TL.LogMessage("ExitIf", "Object Count: " + +ObjectsCount + ", Server Lock Count: " + ServerLockCount + ", Started by COM: " + StartedByCOM);
         if ((ObjectsCount <= 0) && (ServerLockCount <= 0))
         {
             if (StartedByCOM)
             {
                 UIntPtr wParam = new UIntPtr(0);
                 IntPtr  lParam = new IntPtr(0);
                 OCSimulator.TL.LogMessage("ExitIf", "Posting WM_QUIT to Main Thread. Thread ID:" + MainThreadId.ToString() + ", wParam: " + wParam.ToString() + ", lParam: " + lParam.ToString());
                 bool success    = PostThreadMessage(MainThreadId, WM_QUIT, wParam, lParam);
                 int  returnCode = Marshal.GetLastWin32Error();
                 OCSimulator.TL.LogMessage("ExitIf", "WM_QUIT outcome. Success: " + success + ", return code: " + returnCode.ToString("X"));
             }
         }
     }
 }
Пример #2
0
 // AttemptToTerminateServer() will check to see if the objects count and the server
 // lock count have both dropped to zero.
 //
 // If so, and if we were started by COM, we post a WM_QUIT message to the main thread's
 // message loop. This will cause the message loop to exit and hence the termination
 // of this application. If hand-started, then just trace that it WOULD exit now.
 //
 public static void ExitIf()
 {
     lock (lockObj)
     {
         TelescopeHardware.TL.LogMessage("ExitIf", "Object Count: " + +ObjectsCount + ", Server Lock Count: " + ServerLockCount + ", Started by COM: " + m_bComStart);
         if ((ObjectsCount <= 0) && (ServerLockCount <= 0))
         {
             if (m_bComStart)
             {
                 UIntPtr wParam = new UIntPtr(0);
                 IntPtr  lParam = new IntPtr(0);
                 TelescopeHardware.TL.LogMessage("ExitIf", "Posting WM_QUIT to Main Thread. Thread ID:" + MainThreadId.ToString() + ", wParam: " + wParam.ToString() + ", lParam: " + lParam.ToString());
                 bool success    = PostThreadMessage(MainThreadId, 0x0012, wParam, lParam);
                 int  returnCode = Marshal.GetLastWin32Error();
                 TelescopeHardware.TL.LogMessage("ExitIf", "WM_QUIT outcome. Succcess: " + success + ", return code: " + returnCode.ToString("X"));
                 global::TelescopeSimulator.Alpaca.Program.Shutdown();
             }
         }
     }
 }