protected override void OnStart(string[] args) { StopServiceHost(); this.service = new FanControlService(); this.host = new ServiceHost(service); this.host.Open(); }
private void StopServiceHost() { try { if (this.host != null) { if (this.host.State == CommunicationState.Faulted) { this.host.Abort(); } else { this.host.Close(); } this.host = null; } } finally { if (this.service != null) { this.service.Dispose(); this.service = null; } } }