private void FormDesktopWatcher_FormClosing(object sender, FormClosingEventArgs e) { try { // Try sending the message, even though the pipe could // be closed, transmitting, or not even open yet mProcessManager.SendCommandAsync(ProcessManager.COMMAND_CLOSING + "@reason=" + e.CloseReason).Wait(100); mProcessManager.Close(); } catch { } }
void ApplicationExit(string reason) { if (mExiting) { return; } mExiting = true; try { mHttpServer.Stop(); } catch { } try { mBeacon.Stop(); } catch { } // Try sending the message, even though the pipe could // be closed, transmitting, or not even open yet try { mProcessManager.SendCommandAsync(ProcessManager.COMMAND_CLOSING + reason).Wait(100); } catch { } try { mProcessManager.Close(); } catch { } Application.Exit(); }