DevicesManager.RemoveDeviceAsync Method (String, Guid)
Asynchronously removes a device from the database.
Namespace: Microsoft.WindowsServerSolutions.Common.Devices
Assembly: DevicesOM (in DevicesOM.dll)
Syntax
public void RemoveDeviceAsync(
string deviceId,
Guid deviceType
)
public:
void RemoveDeviceAsync(
String^ deviceId,
Guid deviceType
)
Public Sub RemoveDeviceAsync (
deviceId As String,
deviceType As Guid
)
Parameters
deviceId
Type: System.StringThe identifier of the device to be removed.
deviceType
Type: System.GuidThe type of the device to be removed.
Exceptions
Exception | Condition |
---|---|
ArgumentNullException | The argument is null or empty. |
ArgumentException | The deviceType is Guid.Empty. |
DeviceTypeMismatchedException | The deviceType does not match the existing device. |
Remarks
The caller of this method must subscribe to the RemoveDeviceCompleted event to know the result of the removal operation. ReportOperationCompletedEventArgs.Error should also be checked to know whether an error occurred with the operation.
Administrator rights are required to perform this operation.
Examples
The following code example shows how to asynchronously remove a device from the database.
using (DevicesManager dm = new DevicesManager())
{
string deviceId = Guid.NewGuid().ToString();
Guid deviceType = Constant.MyDeviceType;
dm.RemoveDeviceCompleted +=
new EventHandler<ReportOperationCompletedEventArgs>(
dm_RemoveDeviceCompleted);
dm.RemoveDeviceAsync(deviceId, deviceType);
}
static void dm_RemoveDeviceCompleted(object sender,
ReportOperationCompletedEventArgs e)
{
if (e.Error == null)
{
Console.WriteLine("Successfully removed device {0}", e.DeviceId);
}
else
{
Console.WriteLine(e.Error.ToString());
}
}
See Also
DevicesManager Class
Microsoft.WindowsServerSolutions.Common.Devices Namespace
Return to top