PluginData.OnGetData Method (Windows Embedded CE 6.0)

1/5/2010

Override this method to implement the code that calls the device side application and retrieves data.

Namespace: Microsoft.RemoteToolSdk.PluginComponents
Assembly: Microsoft.RemoteToolSdk (in microsoft.remotetoolsdk.dll)

Syntax

protected virtual void OnGetData ()
'Declaration
Protected Overridable Sub OnGetData

Remarks

To send a command to the device and get a return value, use the CommandTransport.ProcessCommand method of the P:Microsoft.RemoteToolSdk.PluginComponents.PluginData.CommandTransport property.

Example

In the following example, a T:Microsoft.RemoteToolSdk.PluginComponents.CommandPacket is created with an ID of 1 and sent to the device. Upon return, the return value Command Packet contains a WORD, a DWORD, a string, and an array of bytes.

The code will store this information by converting all of the return values to strings and adding them to an array. Once the data has been fetched, setting the P:Microsoft.RemoteToolSdk.PluginComponents.PluginData.Initialized property to TRUE will cause any views associated with this data object to refresh.

protected override void OnGetData()
{
    this.strings.Clear(); // Just an array of strings.

    CommandPacket sendCommand = new CommandPacket();
    //
    // Populate the command object (command value of 1)
    //
    sendCommand.CommandId = 1;
    //
    // Process the command
    //
    CommandPacket receivedCommand = 
        base.CommandTransport.ProcessCommand(
            sendCommand, 
            this
        );
    //
    // Place results in data items
    // The device side app builds and returns a packet 
    // with a WORD, a DWORD, a string, and 4 bytes,
    //
    UInt16 w = receivedCommand.GetParameterWORD();
    strings.Add(w.ToString());

    UInt32 dw = receivedCommand.GetParameterDWORD();
    strings.Add(dw.ToString());

    string s = receivedCommand.GetParameterString();
    strings.Add(s);

    byte[] bytes = receivedCommand.GetParameterBytes();
    string fmt = "";
    foreach (byte b in bytes)
    {
        fmt = fmt + b.ToString() + " ";
    }
    strings.Add(fmt);
    //
    // Any view(s) associated with this data will refresh
    //
    this.Initialized = true;
}

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread-safe. Any instance members are not guaranteed to be thread-safe.

See Also

Reference

PluginData Class
PluginData Members
Microsoft.RemoteToolSdk.PluginComponents Namespace