protected override void OnStop() { Logger.RecordOperation("Stop"); _checkTokenSource?.Cancel(); _checkTokenSource?.Dispose(); _checkTokenSource = null; DeviceUsbHelper.UnregisterNotification(_notificationHandle); _notificationHandle = IntPtr.Zero; }
protected override async void OnStart(string[] args) { Logger.RecordOperation("Start"); await Settings.LoadAsync(); Logger.RecordOperation($"Settings IsLoaded: {Settings.IsLoaded}"); _checkTokenSource?.Dispose(); _checkTokenSource = new(); _switcher = new DeviceSwitcher(Settings, Logger); await _switcher.CheckAsync("Initial Check", _checkTokenSource.Token); DeviceUsbHelper.UnregisterNotification(_notificationHandle); _notificationHandle = DeviceUsbHelper.RegisterServiceNotification(this.ServiceHandle); }