Stop() public method

public Stop ( ) : void
return void
Example #1
0
        /// <summary>
        /// Release resources used for WiFi Test
        /// </summary>
        private void ReleaseWiFi()
        {
            // Stop the watcher
            if (_watcher != null)
            {
                if (_watcher.Status == DeviceWatcherStatus.Started)
                {
                    _watcher.Stop();
                }
                _watcher.Added   -= _watcher_Added;
                _watcher.Removed -= _watcher_Removed;
            }

            if (_deviceList != null)
            {
                foreach (var device in _deviceList)
                {
                    device.AvailableNetworksChanged -= device_AvailableNetworksChanged;
                }
                _deviceList.Clear();
            }

            listWiFi.Items.Clear();

            _started = false;
        }
Example #2
0
 async void StopWatcher(object sender, RoutedEventArgs eventArgs)
 {
     try
     {
         if (watcher.Status == Windows.Devices.Enumeration.DeviceWatcherStatus.Stopped)
         {
             await dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
             {
                 OutputText.Text = "The enumeration is already stopped.";
             });
         }
         else
         {
             watcher.Stop();
         }
     }
     catch (ArgumentException)
     {
         await dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
         {
             OutputText.Text = "Caught ArgumentException. Failed to stop watcher.";
         });
     }
     this.btnWatchDevices.IsEnabled = true;
     this.btnStop.IsEnabled         = !(this.btnWatchDevices.IsEnabled);
 }
Example #3
0
        static public void Stop()
        {
            /// <summary>
            /// Stops watching for all nearby Bluetooth devices.
            /// </summary>
            if (deviceWatcher != null)
            {
                // Unregister the event handlers.
                deviceWatcher.Added -= DeviceWatcher_Added;

                // Stop the watcher.
                deviceWatcher.Stop();
                deviceWatcher = null;
            }
        }
Example #4
0
 public IDisposable Connect()
 {
     watcher.Start();
     return(Disposable.Create(() => watcher.Stop()));
 }