private void Exit(object sender, EventArgs e) { if (AudioMonitor != null) { AudioMonitor.Changed -= OnAudioStateChanged; AudioMonitor.Stop(); } if (postInitializationTimer.Enabled) { postInitializationTimer.Stop(); } foreach (EarbudsMenuItem earbudsMenuItem in PairedDeviceMenuItems) { earbudsMenuItem.Stop(); } bleAdvertisementWatcher.Received -= OnBleAdvertisementUpdated; bleAdvertisementWatcher.DestoryBleWatcher(); bluetoothWatcher.Received -= OnBluetoothDeviceUpdated; bluetoothWatcher.Stop(); ValueSet exitMessage = new ValueSet { { "exit", "" } }; systrayApplicationServiceConnection.SendMessageAsync(exitMessage); Application.Exit(); }
public void Stop() { bleAdvertisementWatcher.Received -= OnBleAdvertisementUpdated; bleAdvertisementWatcher.DestoryBleWatcher(); bluetoothWatcher.Received -= OnBluetoothDeviceUpdated; bluetoothWatcher.Stop(); PairingManager.FeatureStateChanged -= PairingManagerFeagtureChanged; PairingManager.Start(); PairedDeviceList.Clear(); BleDeviceUpdated?.Invoke(this, DeviceWatchEvent.Stopped, null); PairedDeviceUpdated?.Invoke(this, DeviceWatchEvent.Stopped, null); }