本文整理汇总了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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例7: StartListeningForSerialPortChanges
private void StartListeningForSerialPortChanges()
{
serialPortWatcher = DeviceInformation.CreateWatcher(SerialDevice.GetDeviceSelector());
serialPortWatcher.Added += SerialPortWatcher_Added;
serialPortWatcher.Removed += SerialPortWatcher_Removed;
serialPortWatcher.Updated += SerialPortWatcher_Updated;
serialPortWatcher.Start();
}
示例8: ConnectedDevicePresenter
public ConnectedDevicePresenter(CoreDispatcher dispatcher)
{
this.dispatcher = dispatcher;
usbConnectedDevicesWatcher = DeviceInformation.CreateWatcher(usbDevicesSelector);
usbConnectedDevicesWatcher.EnumerationCompleted += DevicesEnumCompleted;
usbConnectedDevicesWatcher.Updated += DevicesAdded;
usbConnectedDevicesWatcher.Removed += DevicesRemoved;
usbConnectedDevicesWatcher.Start();
}
示例9: Scenario2_Polling
public Scenario2_Polling()
{
String customSensorSelector = "";
this.InitializeComponent();
customSensorSelector = CustomSensor.GetDeviceSelector(GUIDCustomSensorDeviceVendorDefinedTypeID);
watcher = DeviceInformation.CreateWatcher(customSensorSelector);
watcher.Added += OnCustomSensorAdded;
watcher.Start();
}
示例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();
}
示例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);
}
}
示例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);
}
示例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.";
}
}
示例14: InitDiscovery
private void InitDiscovery()
{
discoverTask = null;
deviceWatcher = DeviceInformation.CreateWatcher(DeviceClass.PortableStorageDevice);
if (deviceWatcher != null)
{
deviceWatcher.Added += DeviceAdded;
deviceWatcher.Removed += DeviceRemoved;
deviceWatcher.Start();
}
}
示例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();
}