-api-id | -api-type |
---|---|
M:Windows.Devices.Enumeration.DeviceInformation.CreateWatcher(System.String) |
winrt method |
Creates a DeviceWatcher for devices matching the specified Advanced Query Syntax (AQS) string.
An AQS string that filters the DeviceInformation objects to enumerate. Typically this string is retrieved from the GetDeviceSelector method of a class that interacts with devices. For example, GetDeviceSelector retrieves the string for the StorageDevice class.
The created DeviceWatcher.
Note
This overload is not available from JavaScript. To create a DeviceWatcher from an AQS string in JavaScript, use the CreateWatcher(String, IIterable_1) overload and pass null
as the second parameter.
The DeviceWatcher first performs an initial enumeration of devices, raising an Added event for each device that it finds, and raising an EnumerationCompleted event when the initial enumeration is complete. After the initial enumeration is complete, it raises events when a device is added, deleted, or updated.
Note
An app must subscribe to all of the added, removed, and updated events to be notified when there are device additions, removals or updates. If an app handles only the added event, it will not receive an update if a device is added to the system after the initial device enumeration completes.
See the DeviceWatcher class for an example.
CreateWatcher, CreateWatcher(DeviceClass), CreateWatcher(String, IIterable_1)