Online-Event

Hello,

i need to know, if my device is connected via gprs, active sync or whatever.
Always when the device gets disconnected, the system changes the icon for the "online-status" in the titlebar. Is it possible to use this event in my application too Or do you know another event-notification which fires an event, when the device gets connected or disconnected Is it also possible with OpenNetCF

Thanks


Answer this question

Online-Event

  • Monish Nagisetty

    The MSDN documentation should provide enough info to figure out which property to use.

    I'd try the SystemState.ConnectionsCount property.



  • Carlos Quintero MVP

    I don't know why, but suddenly it works. The code is still the same

  • CaRNaGe_46038

    That was my first idea. But the problem is I don't recieve any event. After that, I have tried it with ActiveSyncStatus and CradlePresent, but it doesn't work too. I can close the ActiveSync-Connection, take the PDA out of the cradle, ... -> there is no event.

    My test-code:
    public class OnlineManager
    {
    private static int i = 0;
    private static OnlineManager manager;

    SystemState _connectionCount;
    SystemState _activeSyncStat;
    SystemState _cradlePresent;

    private OnlineManager()
    {
    _connectionCount = new SystemState(SystemProperty.ConnectionsCount);
    _connectionCount.Changed += new ChangeEventHandler(_connection_Changed);
    _activeSyncStat = new SystemState(SystemProperty.ActiveSyncStatus);
    _activeSyncStat.Changed += new ChangeEventHandler(_active_Sync_Stat);
    _cradlePresent = new SystemState(SystemProperty.CradlePresent);
    _cradlePresent.Changed += new ChangeEventHandler(_cradle_Present);

    de.csc_dd.mBisProto.mBisProtoHelper.FileHelper.WriteFile("ConCount"+(i + 1).ToString() + ".txt", SystemState.ConnectionsCount.ToString());
    i++;
    de.csc_dd.mBisProto.mBisProtoHelper.FileHelper.WriteFile("Active" + (i + 1).ToString() + ".txt", SystemState.ActiveSyncStatus.ToString());
    i++;
    de.csc_dd.mBisProto.mBisProtoHelper.FileHelper.WriteFile("Cradle" + (i + 1).ToString() + ".txt", SystemState.CradlePresent.ToString());
    i++;
    }

    void _cradle_Present(object sender, ChangeEventArgs args)
    {
    de.csc_dd.mBisProto.mBisProtoHelper.FileHelper.WriteFile("ConCountCC" + (i + 1).ToString() + ".txt", SystemState.ConnectionsCount.ToString());
    i++;
    de.csc_dd.mBisProto.mBisProtoHelper.FileHelper.WriteFile("ActiveCC" + (i + 1).ToString() + ".txt", SystemState.ActiveSyncStatus.ToString());
    i++;
    de.csc_dd.mBisProto.mBisProtoHelper.FileHelper.WriteFile("CradleCC" + (i + 1).ToString() + ".txt", SystemState.CradlePresent.ToString());
    i++;
    }

    void _connection_Changed(object sender, ChangeEventArgs args)
    {
    de.csc_dd.mBisProto.mBisProtoHelper.FileHelper.WriteFile("ConCountPP" + (i + 1).ToString() + ".txt", SystemState.ConnectionsCount.ToString());
    i++;
    de.csc_dd.mBisProto.mBisProtoHelper.FileHelper.WriteFile("ActivePP" + (i + 1).ToString() + ".txt", SystemState.ActiveSyncStatus.ToString());
    i++;
    de.csc_dd.mBisProto.mBisProtoHelper.FileHelper.WriteFile("CradlePP" + (i + 1).ToString() + ".txt", SystemState.CradlePresent.ToString());
    i++;
    }

    void _active_Sync_Stat(object sender, ChangeEventArgs args)
    {
    de.csc_dd.mBisProto.mBisProtoHelper.FileHelper.WriteFile("ConCountTT" + (i + 1).ToString() + ".txt", SystemState.ConnectionsCount.ToString());
    i++;
    de.csc_dd.mBisProto.mBisProtoHelper.FileHelper.WriteFile("ActiveTT" + (i + 1).ToString() + ".txt", SystemState.ActiveSyncStatus.ToString());
    i++;
    de.csc_dd.mBisProto.mBisProtoHelper.FileHelper.WriteFile("CradleTT" + (i + 1).ToString() + ".txt", SystemState.CradlePresent.ToString());
    i++;
    }

    public static void Start()
    {
    if (manager == null)
    manager = new OnlineManager();
    }
    }

    The class works, because the 3 files in the constructor are written, but thats it. Do I have any mistakes in may code or...

    Thanks

  • XNA Rockstar

    Take a look at the Microsoft.WindowsMobile.Status


  • Alvin Kuiper

    Thanks for your help. But still i have some problems with it. Do you know which kind of SystemProperty I have to use I only want to know, if the system has any connection. It doesn't matter if it is via GPRS, ActiveSync or whatever. Or do you know where i can find a more detailed description about that.

    Thanks a lot

  • Online-Event