PnpObjectWatcher.Stop Method

Definition

Important

We no longer recommend that you use the types in the Windows.Devices.Enumeration.Pnp namespace. Instead, the types in the Windows.Devices.Enumeration namespace implement a modern, and better maintained, superset of the functionality of Windows.Devices.Enumeration.Pnp.

The alternative to PnpObjectType is the Windows.Devices.Enumeration.DeviceInformationKind enum, which you can pass as a parameter to Windows.Devices.Enumeration APIs. For example, instead of using PnpObjectType when you create a PnpObjectWatcher, use DeviceInformationKind when you create a DeviceWatcher.

Stops raising the events to inform the client that a PnpObject has been added, updated, or removed.

public:
 virtual void Stop() = Stop;
void Stop();
public void Stop();
function stop()
Public Sub Stop ()

Remarks

To stop a search for devices, an app calls Stop.

This call transitions the PnpObjectWatcher to the Stopping state and completes immediately. The watcher will transition to the Stopped state once all events that are already in the process of being raised have completed.

Callers may wait for the Stopped event if they need to know when the PnpObjectWatcher has stopped. Callers must wait for the Stopped event before they can call Start to restart the watcher. Callers may unsubscribe from events if they do not want to receive any additional events after Stop but do not want to wait for the Stopped event.

The following diagram shows how the PnpObjectWatcher transitions between the states represented by DeviceWatcherStatus enumeration.

state diagram of DeviceWatcher states

Applies to