Share via


DevicesManager.ReportDevicePropertiesAsync Method (String, IList<DeviceProperty>)

 

Asynchronously reports the properties of a device.

Namespace:   Microsoft.WindowsServerSolutions.Common.Devices
Assembly:  DevicesOM (in DevicesOM.dll)

Syntax

public void ReportDevicePropertiesAsync(
    string deviceId,
    IList<DeviceProperty> properties
)
public:
void ReportDevicePropertiesAsync(
    String^ deviceId,
    IList<DeviceProperty^>^ properties
)
Public Sub ReportDevicePropertiesAsync (
    deviceId As String,
    properties As IList(Of DeviceProperty)
)

Parameters

  • deviceId
    Type: System.String

    The identifier of the device to be reported.

Exceptions

Exception Condition
ArgumentNullException

The argument is null or empty.

Remarks

The caller of this method must subscribe to the ReportDevicePropertiesCompleted 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.

This method is to report the properties of an existing device. Use the DevicePropertyFactory class to create device properties.

The Devices Provider is a local access only provider and cannot be accessed outside the server.

Examples

The following code example shows how to asynchronously report device properties.

DevicesManager dm = new DevicesManager();
dm.Connect();

// create a device
Guid deviceType = DeviceTypes.Client;
string deviceId = Guid.NewGuid().ToString();
string deviceName = "SDK Device";
DeviceIdentityStatus status = DeviceIdentityStatus.Active;
string additionalInfo = null;
ReportDeviceParameters reportParameters = 
   new ReportDeviceParameters(deviceId, deviceName, status, additionalInfo);

dm.ReportDevice(deviceType, reportParameters);

// create properties
string os = "Windows Vista";
int spMajor = 2;
SystemType type = SystemType.AMD64;
OperatingSystemProperty operatingSystemProperty = 
   DevicePropertyFactory.CreateOperatingSystemProperty(os, spMajor, type);

int progress = 70;
bool hasBackup = false;
BackupStatusProperty backupStatusProperty = 
   DevicePropertyFactory.CreateBackupStatusProperty(progress, hasBackup);

IList<DeviceProperty> properties = new List<DeviceProperty>(
   new DeviceProperty[] { operatingSystemProperty, backupStatusProperty });

// report properties
dm.ReportDevicePropertiesCompleted += 
   new EventHandler<ReportOperationCompletedEventArgs>(
      dm_ReportDevicePropertiesCompleted);

dm.ReportDevicePropertiesAsync(deviceId, properties);

The following code example shows the delegate method.

static void dm_ReportDevicePropertiesCompleted(object sender, 
   ReportOperationCompletedEventArgs e)
{
   if (e.Error == null)    // if there was no error
   {
      Console.WriteLine("Successfully reported properties for device {0}",
         e.DeviceId);
   }
   else
   {
      Console.WriteLine(e.Error.ToString()); // print exception
   }
}

See Also

DevicePropertyFactory
DevicesManager Class
Microsoft.WindowsServerSolutions.Common.Devices Namespace

Return to top