protected override void OnStop() { int pid = Process.GetCurrentProcess().Id; LogBook.Write("Stopping exe's"); LogBook.Write(Process.GetCurrentProcess().ProcessName); LogBook.Write("Master Connection String: " + ConfigurationManager.ConnectionStrings["SqlConnectionString"].ConnectionString); foreach (Process pro in Process.GetProcessesByName("CooperAtkins.NotificationClient.Service")) { if (pro.Id != pid) { try { ServiceEntity svcEntity = new ServiceEntity(); svcEntity.PID = pro.Id; svcEntity.ExeName = ConfigurationManager.ConnectionStrings["SqlConnectionString"].ConnectionString; using (ServiceEntityContext context = new ServiceEntityContext()) { LogBook.Write("Executing update for process id: " + pro.Id.ToString()); context.Save(svcEntity, EnterpriseModel.Net.ObjectAction.Edit); } LogBook.Write("Stopping process: " + pro.Id); pro.Kill(); } catch (Exception ex) { LogBook.Write(ex, "Notification Client Service"); } } } /* Uncommented by 5/9/2012 by Mike R. due to missed comm notification problems * Commented By: Srinivas Rao E * Data: 2/2/02/2012 * Description: Timers runs every 3 seconds, so there is no need to listen from external source. */ if (_udpSocket != null) { try { _udpSocket.Close(); _udpSocket.Dispose(); } catch { } finally { _udpSocket = null; } try { _thdUdpHandler.Abort(); } catch (ThreadAbortException) { } } try { _target.Close(); } catch (Exception ex) { LogBook.Write(ex, "Notification Client Service"); } }
private void Form1_FormClosing(object sender, FormClosingEventArgs e) { target.Close(); }