コード例 #1
0
        /// <summary>
        /// Register to be notified when a connection is established to the Bluetooth device
        /// </summary>
        private void StartDeviceConnectionWatcher()
        {
            watcher = PnpObject.CreateWatcher(PnpObjectType.DeviceContainer,
                                              new string[] { "System.Devices.Connected" }, String.Empty);

            watcher.Updated += DeviceConnection_Updated;
            watcher.Start();
        }
コード例 #2
0
        private void StartDeviceConnectionWatcher()
        {
            watcher = PnpObject.CreateWatcher(PnpObjectType.DeviceContainer,
                                              new string[] { "System.Devices.Connected" }, String.Empty);

            Log("Registering device connection watcher updated event handler");
            watcher.Updated += DeviceConnection_Updated;

            Log("Starting device connection watcher");
            watcher.Start();
        }
コード例 #3
0
        async Task <bool> RegisterForConnectionEvents()
        {
            UnregisterForConnectionEvents();

            string    deviceContainerId  = "{" + DeviceContainerId + "}";
            PnpObject containerPnpObject = await PnpObject.CreateFromIdAsync(PnpObjectType.DeviceContainer, deviceContainerId, new string[] { CONNECTED_FLAG_PROPERTY_NAME });

            var  connectedProperty = containerPnpObject.Properties[CONNECTED_FLAG_PROPERTY_NAME];
            bool isConnected       = false;

            Boolean.TryParse(connectedProperty.ToString(), out isConnected);
            _connectionWatcher = PnpObject.CreateWatcher(PnpObjectType.DeviceContainer,
                                                         new string[] { CONNECTED_FLAG_PROPERTY_NAME }, String.Empty);

            _connectionWatcher.Updated -= DeviceConnection_Updated;
            _connectionWatcher.Updated += DeviceConnection_Updated;
            _connectionWatcher.Start();

            return(isConnected);
        }
コード例 #4
0
 private void StartDeviceConnectionWatcher()
 {
     _watcher          = PnpObject.CreateWatcher(PnpObjectType.DeviceContainer, new string[] { ConnectedProperty }, String.Empty);
     _watcher.Updated += DeviceConnection_Updated;
     _watcher.Start();
 }