DevicesManager.ReportDeviceAsync Method (Guid, ReportDeviceParameters)
Asynchronously reports when a new device is added; or when a name, or identity status of a device is updated.
Namespace: Microsoft.WindowsServerSolutions.Common.Devices
Assembly: DevicesOM (in DevicesOM.dll)
Syntax
public void ReportDeviceAsync(
Guid deviceType,
ReportDeviceParameters parameters
)
public:
void ReportDeviceAsync(
Guid deviceType,
ReportDeviceParameters^ parameters
)
Public Sub ReportDeviceAsync (
deviceType As Guid,
parameters As ReportDeviceParameters
)
Parameters
deviceType
Type: System.GuidThe type of the device to be reported.
parameters
Type: Microsoft.WindowsServerSolutions.Common.Devices.ReportDeviceParametersThe parameters that are necessary for reporting a device.
Exceptions
Exception | Condition |
---|---|
ArgumentNullException | The argument is null or empty. |
ArgumentException | The deviceType is Guid.Empty. |
Remarks
The caller of this method must subscribe to the ReportDeviceCompleted event to know the result of the report operation. ReportOperationCompletedEventArgs.Error should also be checked to know whether an error occurred with the operation.
Administrator rights are required to perform this operation.
Only devices with a device type from DeviceTypes are listed in the Dashboard.
Examples
The following code example shows how to asynchronously report a device.
using (DevicesManager dm = new DevicesManager())
{
string deviceId = Guid.NewGuid().ToString();
Guid deviceType = Constant.MyDeviceType;
ReportDeviceParameters reportParameters =
new ReportDeviceParameters(deviceId,
"SDK Device",
DeviceIdentityStatus.Active,
null);
dm.ReportDeviceCompleted +=
new EventHandler<ReportOperationCompletedEventArgs>(
dm_ReportDeviceCompleted);
dm.ReportDevice(deviceType, reportParameters);
}
The following code example shows the delegate method.
static void dm_ReportDeviceCompleted(object sender,
ReportOperationCompletedEventArgs e)
{
if (e.Error == null) // if there was no error
{
Console.WriteLine("Successfully reported device {0}", e.DeviceId);
}
else
{
Console.WriteLine(e.Error.ToString()); // print exception
}
}
See Also
DeviceTypes
DeviceIdentityStatus
ReportDeviceAsync Overload
DevicesManager Class
Microsoft.WindowsServerSolutions.Common.Devices Namespace
Return to top