void StopService() { if (_host != null && _host.State == CommunicationState.Opened) { _host.Close(); if (_service != null) { _service.Dispose(); _service = null; } } if (_configHost != null && _configHost.State == CommunicationState.Opened) { _configHost.Close(); _configHost.SystemChanged -= _configHost_SystemChanged; } OnPropertyChanged("HostInfo"); }
void StartService() { try { _configHost = new ConfigServiceHost(typeof(NovaAlertConfigService)); _configHost.Open(); _configHost.SystemChanged += _configHost_SystemChanged; _service = new NovaAlertService(); _host = new ServiceHost(_service); _host.Open(); _host.Faulted += OnHostFaulted; } catch (Exception ex) { ServiceContainer.Instance.GetService <IMessageBoxService>().ShowError(ex.Message); } finally { OnPropertyChanged("HostInfo"); } }