-api-id | -api-type |
---|---|
M:Windows.Devices.Enumeration.DeviceInformation.CreateWatcher(System.String,Windows.Foundation.Collections.IIterable{System.String}) |
winrt method |
Creates a DeviceWatcher for devices matching the specified Advanced Query Syntax (AQS) string and the specified collection of properties.
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.
An iterable list of additional properties to include in the Properties property of the DeviceInformation objects in the enumeration results. For more info on what the properties represent, see Device information properties.
The created DeviceWatcher.
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)