protected override void OnStop() { this.Trace("service is stopping..."); // if (null != this.usbMonitor) { this.usbMonitor.Stop(); this.usbMonitor.Dispose(); this.usbMonitor = null; } this.OleUninitialize(); // this.Trace("...service has stopped"); }
protected override void OnStart(string[] args) { this.Trace("service is starting..."); // try { WIN32.OleInitialize(IntPtr.Zero); this.oleInitialized = true; // this.usbMonitor = new USBMonitor(this, this, this.ServiceHandle, true); this.usbMonitor.AddDeviceInterfaceOfInterest(AndroidADBDeviceInterface); this.usbMonitor.Start(); } catch (Exception e) { this.ExitCode = WIN32.ERROR_EXCEPTION_IN_SERVICE; this.ServiceSpecificExitCode = WIN32.Win32ErrorFromException(e); this.Trace($"exception: {e}"); throw; } // this.Trace("...service has started"); }