当前位置: 首页>>代码示例>>C#>>正文


C# DeviceWatcher.Start方法代码示例

本文整理汇总了C#中Windows.Devices.Enumeration.DeviceWatcher.Start方法的典型用法代码示例。如果您正苦于以下问题:C# DeviceWatcher.Start方法的具体用法?C# DeviceWatcher.Start怎么用?C# DeviceWatcher.Start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Windows.Devices.Enumeration.DeviceWatcher的用法示例。


在下文中一共展示了DeviceWatcher.Start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExternalDeviceService

 public ExternalDeviceService()
 {
     _deviceWatcher = DeviceInformation.CreateWatcher(DeviceClass.PortableStorageDevice);
     _deviceWatcher.Added += DeviceAdded;
     _deviceWatcher.Removed += DeviceRemoved;
     _deviceWatcher.Start();
 }
开发者ID:robUx4,项目名称:vlc-winrt,代码行数:7,代码来源:ExternalDeviceService.cs

示例2: UsbScopeDevice

 public UsbScopeDevice()
 {
     var usbScopeSelector = HidDevice.GetDeviceSelector(UsagePage, UsageId, Vid, Pid);
     ScopeDeviceWatcher = DeviceInformation.CreateWatcher(usbScopeSelector);
     ScopeDeviceWatcher.Added += new TypedEventHandler<DeviceWatcher, DeviceInformation>(OnDeviceAdded);
     ScopeDeviceWatcher.Removed += new TypedEventHandler<DeviceWatcher, DeviceInformationUpdate>(OnDeviceRemoved);
     ScopeDeviceWatcher.Start();
 }
开发者ID:gazzyt,项目名称:GaryScope,代码行数:8,代码来源:UsbScopeDevice.cs

示例3: Scenario4_BackgroundProximitySensor

        public Scenario4_BackgroundProximitySensor()
        {
            this.InitializeComponent();

            watcher = DeviceInformation.CreateWatcher(ProximitySensor.GetDeviceSelector());
            watcher.Added += OnProximitySensorAdded;
            watcher.Start();
        }
开发者ID:C-C-D-I,项目名称:Windows-universal-samples,代码行数:8,代码来源:Scenario4_BackgroundProximitySensor.xaml.cs

示例4: NetworkPresenter

 public NetworkPresenter()
 {
     WiFiAdaptersWatcher = DeviceInformation.CreateWatcher(WiFiAdapter.GetDeviceSelector());
     WiFiAdaptersWatcher.EnumerationCompleted += AdaptersEnumCompleted;
     WiFiAdaptersWatcher.Added += AdaptersAdded;
     WiFiAdaptersWatcher.Removed += AdaptersRemoved;
     WiFiAdaptersWatcher.Start();
 }
开发者ID:MicrosoftEdge,项目名称:WebOnPi,代码行数:8,代码来源:NetworkPresenter.cs

示例5: OnNavigatedTo

 protected async override void OnNavigatedTo(NavigationEventArgs e)
 {
     base.OnNavigatedTo(e);
     watcher = DeviceInformation.CreateWatcher(ProximitySensor.GetDeviceSelector());
     watcher.Added += OnProximitySensorAdded;
     watcher.Start();
     timer = new Timer(TimerCallBack, null, Timeout.Infinite, 4000);
     await InitializeCameraAsync();
 }
开发者ID:UWPanda,项目名称:BemeRecorder,代码行数:9,代码来源:MainPage.xaml.cs

示例6: HidGamepad

 static HidGamepad()
 {
     var deviceSelector = HidDevice.GetDeviceSelector(0x01, 0x05);
     _watcher = DeviceInformation.CreateWatcher(deviceSelector);
     _watcher.Added += HandleDeviceAdded;
     _watcher.Updated += HandleDeviceUpdated;
     _watcher.Removed += HandleDeviceRemoved;
     _watcher.EnumerationCompleted += HandleEnumerationCompleted;
     _watcher.Start();
 }
开发者ID:bricelam,项目名称:HidGamepad,代码行数:10,代码来源:HidGamepad.cs

示例7: StartListeningForSerialPortChanges

        private void StartListeningForSerialPortChanges()
        {
            serialPortWatcher = DeviceInformation.CreateWatcher(SerialDevice.GetDeviceSelector());

            serialPortWatcher.Added += SerialPortWatcher_Added;
            serialPortWatcher.Removed += SerialPortWatcher_Removed;
            serialPortWatcher.Updated += SerialPortWatcher_Updated;

            serialPortWatcher.Start();
        }
开发者ID:moszinet,项目名称:MosziNet.XBee,代码行数:10,代码来源:XBeeSerialPort.cs

示例8: ConnectedDevicePresenter

    public ConnectedDevicePresenter(CoreDispatcher dispatcher)
    {
      this.dispatcher = dispatcher;

      usbConnectedDevicesWatcher = DeviceInformation.CreateWatcher(usbDevicesSelector);
      usbConnectedDevicesWatcher.EnumerationCompleted += DevicesEnumCompleted;
      usbConnectedDevicesWatcher.Updated += DevicesAdded;
      usbConnectedDevicesWatcher.Removed += DevicesRemoved;
      usbConnectedDevicesWatcher.Start();
    }
开发者ID:SteamMaker,项目名称:haxc,代码行数:10,代码来源:ConnectedDevicePresenter.cs

示例9: Scenario2_Polling

        public Scenario2_Polling()
        {
            String customSensorSelector = "";

            this.InitializeComponent();

            customSensorSelector = CustomSensor.GetDeviceSelector(GUIDCustomSensorDeviceVendorDefinedTypeID);
            watcher = DeviceInformation.CreateWatcher(customSensorSelector);
            watcher.Added += OnCustomSensorAdded;
            watcher.Start();
        }
开发者ID:t-angma,项目名称:Windows-universal-samples,代码行数:11,代码来源:scenario2_polling.xaml.cs

示例10: Blink1

        static Blink1()
        {
            var selector = HidDevice.GetDeviceSelector(0xFF00, 0x0001, 0x27B8, 0x01ED);

            _watcher = DeviceInformation.CreateWatcher(selector);
            _watcher.Added += HandleDeviceAdded;
            _watcher.Updated += HandleDeviceUpdated;
            _watcher.Removed += HandleDeviceRemoved;
            _watcher.EnumerationCompleted += HandleEnumerationCompleted;
            _watcher.Start();
        }
开发者ID:bricelam,项目名称:ThingM.Blink1,代码行数:11,代码来源:Blink1.cs

示例11: btnWatcher_Click

        private void btnWatcher_Click(object sender, RoutedEventArgs e)
        {
            if (_fWatcherStarted == false)
            {
                _publisher.Start();

                if (_publisher.Status != WiFiDirectAdvertisementPublisherStatus.Started)
                {
                    rootPage.NotifyUser("Failed to start advertisement.", NotifyType.ErrorMessage);
                    return;
                }

                DiscoveredDevices.Clear();
                rootPage.NotifyUser("Finding Devices...", NotifyType.StatusMessage);

                String deviceSelector = WiFiDirectDevice.GetDeviceSelector(
                    Utils.GetSelectedItemTag<WiFiDirectDeviceSelectorType>(cmbDeviceSelector));

                _deviceWatcher = DeviceInformation.CreateWatcher(deviceSelector, new string[] { "System.Devices.WiFiDirect.InformationElements" });

                _deviceWatcher.Added += OnDeviceAdded;
                _deviceWatcher.Removed += OnDeviceRemoved;
                _deviceWatcher.Updated += OnDeviceUpdated;
                _deviceWatcher.EnumerationCompleted += OnEnumerationCompleted;
                _deviceWatcher.Stopped += OnStopped;

                _deviceWatcher.Start();

                btnWatcher.Content = "Stop Watcher";
                _fWatcherStarted = true;
            }
            else
            {
                _publisher.Stop();

                btnWatcher.Content = "Start Watcher";
                _fWatcherStarted = false;

                _deviceWatcher.Added -= OnDeviceAdded;
                _deviceWatcher.Removed -= OnDeviceRemoved;
                _deviceWatcher.Updated -= OnDeviceUpdated;
                _deviceWatcher.EnumerationCompleted -= OnEnumerationCompleted;
                _deviceWatcher.Stopped -= OnStopped;

                _deviceWatcher.Stop();

                rootPage.NotifyUser("Device watcher stopped.", NotifyType.StatusMessage);
            }
        }
开发者ID:polarapfel,项目名称:Windows-universal-samples,代码行数:49,代码来源:Scenario2_Connector.xaml.cs

示例12: Scenario2_Polling

        public Scenario2_Polling()
        {
            String customSensorSelector = "";

            this.InitializeComponent();

            customSensorSelector = CustomSensor.GetDeviceSelector(GUIDCustomSensorDeviceVendorDefinedTypeID);
            watcher = DeviceInformation.CreateWatcher(customSensorSelector);
            watcher.Added += OnCustomSensorAdded;
            watcher.Start();

            // Register to be notified when the user disables access to the custom sensor through privacy settings.
            deviceAccessInformation = DeviceAccessInformation.CreateFromDeviceClassId(GUIDCustomSensorDeviceVendorDefinedTypeID);
            deviceAccessInformation.AccessChanged += new TypedEventHandler<DeviceAccessInformation, DeviceAccessChangedEventArgs>(OnAccessChanged);
        }
开发者ID:RasmusTG,项目名称:Windows-universal-samples,代码行数:15,代码来源:Scenario2_Polling.xaml.cs

示例13: WatchDevices_Click

        //public ObservableCollection<clsDevType> DevTypes = new ObservableCollection<clsDevType>();

        async void WatchDevices_Click(object sender, RoutedEventArgs eventArgs)
        {
            if (watcher != null)
            {
                watcher = null;
            }
            count = 0; 
            isEnumerationComplete = false;
            StopStatus = null;
            //DeviceInterfacesOutputList.Items.Clear();

            try
            {
                dispatcher = Window.Current.CoreWindow.Dispatcher;
                watcher = DeviceInformation.CreateWatcher();
                // Add event handlers
                watcher.Added += watcher_Added;
                watcher.Removed += watcher_Removed;
                watcher.Updated += watcher_Updated;
                watcher.EnumerationCompleted += watcher_EnumerationCompleted;
                watcher.Stopped += watcher_Stopped;
                watcher.Start();
                OutputText.Text = "Enumeration started.";

                this.btnWatchDevices.IsEnabled = false;
                this.btnStop.IsEnabled = !(this.btnWatchDevices.IsEnabled);


            }
            catch (ArgumentException)
            {
                //The ArgumentException gets thrown by FindAllAsync when the GUID isn't formatted properly
                //The only reason we're catching it here is because the user is allowed to enter GUIDs without validation
                //In normal usage of the API, this exception handling probably wouldn't be necessary when using known-good GUIDs 
                OutputText.Text = "Caught ArgumentException. Failed to create watcher.";
            }
        }
开发者ID:djaus2,项目名称:WindowsDevices,代码行数:39,代码来源:MainPage.xaml.cs

示例14: InitDiscovery

        private void InitDiscovery()
        {

            discoverTask = null;

            deviceWatcher = DeviceInformation.CreateWatcher(DeviceClass.PortableStorageDevice);
            if (deviceWatcher != null)
            {
                deviceWatcher.Added += DeviceAdded;
                deviceWatcher.Removed += DeviceRemoved;
                deviceWatcher.Start();
            }
        }
开发者ID:flecoqui,项目名称:Windows10,代码行数:13,代码来源:MainPage.xaml.cs

示例15: StartWatcher

        void StartWatcher()
        {
            //deviceWatcher = DeviceInformation.CreateWatcher(UsbDevice.GetDeviceSelector(0x04d8, 0xf426));
            deviceWatcher = DeviceInformation.CreateWatcher(UsbDevice.GetDeviceSelector(TreehopperUsb.Settings.Vid, TreehopperUsb.Settings.Pid));
            // Hook up handlers for the watcher events before starting the watcher

            handlerAdded = new TypedEventHandler<DeviceWatcher, DeviceInformation>(async (watcher, deviceInfo) =>
            {
                Debug.WriteLine("Device added: " + deviceInfo.Name);

                UsbConnection newConnection = new UsbConnection(deviceInfo);

                TreehopperUsb newBoard = new TreehopperUsb(newConnection);
                await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    connectedDevices.Add(newBoard);
                });
                try
                {
                    if (boardAddedSignal.CurrentCount == 0)
                        boardAddedSignal.Release();
                }
                catch { }
            });
            deviceWatcher.Added += handlerAdded;

            handlerUpdated = new TypedEventHandler<DeviceWatcher, DeviceInformationUpdate>((watcher, deviceInfoUpdate) =>
            {
                Debug.WriteLine("Device updated");
            });
            deviceWatcher.Updated += handlerUpdated;

            handlerRemoved = new TypedEventHandler<DeviceWatcher, DeviceInformationUpdate>(async (watcher, deviceInfoUpdate) =>
            {
                Debug.WriteLine("Device removed");
                await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    connectedDevices.Where(board => ((UsbConnection)(board.Connection)).DevicePath == deviceInfoUpdate.Id).ToList().All(i =>
                    {
                        i.Disconnect();
                        connectedDevices.Remove(i);
                        return true;
                    }
                    );
                });
            });
            deviceWatcher.Removed += handlerRemoved;

            handlerEnumCompleted = new TypedEventHandler<DeviceWatcher, Object>((watcher, obj) =>
            {
                Debug.WriteLine("Enum completed");
            });
            deviceWatcher.EnumerationCompleted += handlerEnumCompleted;

            handlerStopped = new TypedEventHandler<DeviceWatcher, Object>((watcher, obj) =>
            {
                Debug.WriteLine("Device or something stopped");
            });
            deviceWatcher.Stopped += handlerStopped;

            Debug.WriteLine("Starting the wutchah");
            deviceWatcher.Start();
        }
开发者ID:treehopper-electronics,项目名称:treehopper-sdk,代码行数:63,代码来源:ConnectionService.cs


注:本文中的Windows.Devices.Enumeration.DeviceWatcher.Start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。