Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

PnpObjectWatcher class

Applies to Windows and Windows Phone

Raises events to notify the client that a PnpObject has been added, updated, or removed from an enumerated collection of Pnp device objects in an incremental and asynchronous way.

Syntax


public sealed class PnpObjectWatcher

Attributes

[DualApiPartition()]
[MarshalingBehavior(Agile)]
[Version(0x06020000)]

Members

The PnpObjectWatcher class has these types of members:

Events

The PnpObjectWatcher class has these events.

EventDescription
Added Occurs when a PnpObject is added to the collection enumerated by the PnpObjectWatcher.
EnumerationCompleted Occurs when the enumeration of Pnp device objects has been completed.
Removed Occurs when a PnpObject is removed from the collection enumerated by the PnpObjectWatcher.
Stopped Occurs when the PnpObjectWatcher has stopped monitoring changes to the collection of Pnp device objects.
Updated Occurs when the properties of a PnpObject in the collection enumerated by the PnpObjectWatcher are updated.

 

Methods

The PnpObjectWatcher class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.

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

 

Properties

The PnpObjectWatcher class has these properties.

PropertyAccess typeDescription

Status

Read-onlyThe status associated with the asynchronous operation.

 

Remarks

An app calls Start to begin the search for devices. During this intial enumeration, the PnpObjectWatcher raises an Added event for each device that's found, until all devices are found. The PnpObjectWatcher raises an EnumerationCompleted event when the initial enumeration is complete, and continues to raise events if a device is added, updated, or removed.

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

state diagram of DeviceWatcher states

The Start method can only be called when the PnpObjectWatcher is in the Created, Stopped or Aborted state. The Status property indicates the PnpObjectWatcher state. When re-starting the watcher, wait for the Stopped event before calling Start.

A call to Stop 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.

After calling Stop, apps 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.

Requirements

Minimum supported client

Windows 8 [Windows Store apps, desktop apps]

Minimum supported server

Windows Server 2012 [Windows Store apps, desktop apps]

Minimum supported phone

Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]

Namespace

Windows.Devices.Enumeration.Pnp
Windows::Devices::Enumeration::Pnp [C++]

Metadata

Windows.winmd

 

 

Show:
© 2014 Microsoft