Share via


Modifying Plug-in Data for Asynchronous Mode with Native Device-Side Code (Windows Embedded CE 6.0)

1/6/2010

If your plug-in communicates in asynchronous mode and has a device-side component that uses native code, perform the following procedure to modify the data and implement the periodic command packets that are sent back to the desktop-side component.

These steps are performed in addition to the procedure shown in Modifying Plug-in Data for Synchronous Mode with Native Device-Side Code.

For information about the files referenced, see Components of a Plug-in.

To modify data in an asynchronous-mode plug-in with native device-side code

  1. On the device side, in the Async.cs file, modify the implementation in the commandTransport_CommandPacketReceived method to process the new command and return a response to the desktop-side component. To accomplish this, your code must include the following actions.

    • Use the e.CommandPacketIn.CommandId property to identify the new command ID that you added to MyData.cs.
    • Use the e.CommandPacketIn.GetParameterxxx methods to retrieve any parameters that were sent by the desktop side, in the same order that they were packed into the command packet by the desktop-side component.
    • Perform any necessary tasks in the device-side code.
    • Create a new instance of the CommandPacket class, and then use the CommandPacket.AddParameterxxx methods to marshal the data that you want to send back to the desktop into the new CommandPacket instance.
    • Copy the CommandPacket instance to the e.CommandPacketOut property.
  2. On the device side, in the WndProc callback method in the Async.cpp file, modify the implementation within the switch statement’s WM_TIMER case so that it performs the following actions.

    • Call the g_DeviceRemoteTool.CreateCommand method to create a new instance of the CommandPacket class.
    • Call the CommandPacket.AddParameterXXX methods to marshal the data that you want to send back to the desktop.
    • Call the g_DeviceRemoteTool.PushCommand method to push the command back to the desktop, and then call the g_DeviceRemoteTool.FreeCommand method to destroy the instance of the command packet.
  3. To store or display any data about the device-side state in the desktop-side code, store that data in a property of the MyData class.

    Note

    The property must have a public accessor method for this data. If there is no specific property or public accessor method, implement it at this time.

  4. To obtain the data stored in step 3, on the desktop side, in the MyView.cs file, modify the implementation in the MyView.OnPopulateControls method to call the public accessor methods for the MyData object's property. Then call the public accessor methods in the Windows form elements in the MyView.cs file.

  5. Save your changes, and then rebuild the plug-in.

See Also

Concepts

Modifying Data Sent Between Desktop and Device Components