protected override void OnClosing(CancelEventArgs e) { if (MessageBox.Show("您确定关闭服务吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK) { try { if (ServiceContext.Instance.ServiceStarted) { BusinessHandlerFactory.DisposeBusinessHandlerFactories(); } string msg; ServiceContext.Instance.StopService(out msg); } catch (Exception ex) { LoggerHelper.Instance.Error(ex); } NeedClose = true; e.Cancel = false; base.OnClosing(e); } else { NeedClose = false; e.Cancel = true; } }
/// <summary> /// 服务关闭了。 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void serviceHost_Closed(object sender, EventArgs e) { //serviceHostPharmacyService = null; BusinessHandlerFactory.DisposeBusinessHandlerFactories(); ServiceStarted = false; }