private void ServiceChecker() { while (true) { if ((this._softGetaway != null) && (this._softGetaway.State == System.ServiceModel.CommunicationState.Faulted)) this._softGetaway = null; if (this._softGetaway == null) { if (testServiceInstalled) { var ctl = (from s in ServiceController.GetServices() where (s.ServiceName.Equals("Software Getaway")) select s).FirstOrDefault(); varContainer.IsServiceInstalled = (ctl != null); if (varContainer.IsServiceInstalledTrue) { if (ctl != null) { if (ctl.Status.Equals(ServiceControllerStatus.Running)) varContainer.IsServiceStarted = true; else if (ctl.Status.Equals(ServiceControllerStatus.Stopped)) varContainer.IsServiceStarted = false; else varContainer.IsServiceStarted = null; } } } if ((!testServiceInstalled) || (varContainer.IsServiceStartedTrue)) this.ConnectService(); } testService.WaitOne(5000); } }
private void ConnectService() { if (this._softGetaway == null) { this._softGetaway = new softGetawayClient.softGetawayService.SoftGetawayHostClient(); this._softGetaway.InnerChannel.Faulted += new EventHandler(InnerChannel_Faulted); this._softGetaway.InnerChannel.Closed += new EventHandler(InnerChannel_Closed); this._softGetaway.InnerChannel.Opened += new EventHandler(InnerChannel_Opened); try { this._softGetaway.Open(); } catch (Exception ex) { } } }