locked
How can I detect when Device is connected to pc C# and ActiveSync RRS feed

  • Question

  • Hello I'm using rapi2 to copy files from device to pc. And I want to detect when device is connected to computer.

    Now I'm using RemoteDeviceManager and provided events DeviceConnected and DeviceDisconnected

     

    public MainForm()

    {

    InitializeComponent();

    manager = new RemoteDeviceManager();

    manager.DeviceConnected += new EventHandler(manager_DeviceConnected);

    manager.DeviceDisconnected += new EventHandler(manager_DeviceDisconnected);

    LoadDevices();

    }

    void manager_DeviceDisconnected(object sender, EventArgs e)

    {

    if(!Synchronizing)

    LoadDevices();

    }

    void manager_DeviceConnected(object sender, EventArgs e)

    {

    if(!Synchronizing)

    LoadDevices();

    }

     

    but unfortunetly events seams not working and I don't know why...

    does anyone have any suggestions?

    Tuesday, September 9, 2008 2:22 PM

Answers

  • Hi konrad.b,

    I have no experience about RemoteDeviceManager class,  but you can implement same function using OpennetCF, which wrap RAPI, for more information:

    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2618249&SiteID=1

     

    Best regards,

    Guang-Ming Bian - MSFT

    Thursday, September 11, 2008 2:51 AM
  • Hi

     

    Pay attention to this line:

    manager = new RemoteDeviceManager();

     

    You used the “manager” as a local variable, so it might be GCed before the device was connected. So you need make it persistent, for example, by making it a field of the Form.

     

    manager = new RemoteDeviceManager();

    public MainForm()

    {

     InitializeComponent();

     

     

    Regards

    Chunsheng Tang

     

    Thursday, September 11, 2008 3:18 AM

All replies

  • Hi konrad.b,

    I have no experience about RemoteDeviceManager class,  but you can implement same function using OpennetCF, which wrap RAPI, for more information:

    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2618249&SiteID=1

     

    Best regards,

    Guang-Ming Bian - MSFT

    Thursday, September 11, 2008 2:51 AM
  • Hi

     

    Pay attention to this line:

    manager = new RemoteDeviceManager();

     

    You used the “manager” as a local variable, so it might be GCed before the device was connected. So you need make it persistent, for example, by making it a field of the Form.

     

    manager = new RemoteDeviceManager();

    public MainForm()

    {

     InitializeComponent();

     

     

    Regards

    Chunsheng Tang

     

    Thursday, September 11, 2008 3:18 AM
  •   try this MobileCommunicationFramework.Net

    Its a amazing easy to use Net Wrapper für RAPI2. Its a littel bit easyer than OpenNETCF i think.
    Has somebody try this?
    Monday, March 9, 2009 3:20 PM