Fails to disconnect GPRS on Windows Mobile 6

Last post 09-02-2008 7:05 by neil. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 08-30-2008 12:05

    Fails to disconnect GPRS on Windows Mobile 6

    Hi,

    I am trying to connect my HTC Touch with Windows Mobile 6 to GPRS by the OpenNETCF connection manager. I succeed to connect it but I cannot disconenct it. When I call connect method on that way: "cm.Connect(destguid, TRUE, ConnectionMode.Asynchronous)"  the device succeed to disconnect only if
    the application has not been exchanged any data via internet. When the application exchange some data via internet (call a WEB service method) the status of the connection change to ConectionFailed and the GPRS do not disconnects. Second case: when I use "cm.Connect(destguid, FALSE, ConnectionMode.Asynchronous)" to connect to GPRS, the GPRS cannot disconnects no matter if the application has been exchanged some data with Internet or not, and the connection status of the connection became disconnected but the GPRS does not disconnect. What is the problem. I have tried so many thing to fix the problem but with no success. Please give me some solution for the problem. Is there any other way to connect and disconnect GPRS without OpneNETCF connection manager ? I have purchased
    RAS Library and tried do connects and disconnects using it but with no success, too (the example in the library doesn't work). Please give me some example. I post my source code (connect and disconnect method) and I attach the whole class implementation which I use. I hope you will help me to solve the problem. It is very important to me. Thanks.

    Here is my source code:

    1. Connecting method :

    public void GPRSStart(string connName)
            {
                try
                {
                    bool isset = false;
                    int tries = 0;

                    string gprsConnName = connName;

                    DestinationInfoCollection destInfo = cm.EnumDestinations();
                    foreach (DestinationInfo di in destInfo)
                    {
                        if (di.Description.ToLower() == gprsConnName.ToLower())
                        {
                            destguid = di.Guid;
                            isset = true;
                            break;
                        }
                    }
                    if (isset)
                    {
                        while ((cm.Status != ConnectionStatus.Connected) && tries < 5)
                        {
                            cm.Connect(destguid, false, ConnectionMode.Asynchronous);
                            ++tries;
                            if (cm.Status == ConnectionStatus.Connected)
                            {
                                break;
                            }
                            Thread.Sleep(1000);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }

    2. And the method for disconnecting:

    public void GPRSStop()
            {
                try
                {
                    if (cm == null) return;

                    if (ConnectionStatus.Disconnected != cm.Status)
                    {
                        cm.RequestDisconnect();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }

  • 09-02-2008 7:05 In reply to

    • neil
    • OpenNETCF Staff
    • Top 10 Contributor
    • Joined on 07-30-2007
    • North Wales
    • Posts 1,152

    Re: Fails to disconnect GPRS on Windows Mobile 6

    This is by design. The ConnectionManager class is a wrapper around the native Connection Manager API (ConnMgr) and as such behaves exactly as expected. ConnMgr treats GPRS connections as a special case and overrides any requests to release a GPRS connection. This is because it does not cost any extra, both economically and in terms of resource consumption (CPU, power, or bandwidth), to cache a GPRS connection and let it idle. The flipside of this (frequently establishing and release a connection) introduces significant impedance into an application's workflow due to the length of time it takes to establish a connection. Even if you establish the connection asynchronously, there's a significant delay between needing a connection (the reason to start the connection procedure) and actually being able to use the connection.

    Unqualified statements like "the example in the library doesn't work" do nothing to help us identify the issue with the RAS library. I'm going to assume (based upon your email) you are referring to the fact that the sample application shipped with the RAS SDK does not update the Comm Manager UI when you dial a connection. If that is the case, then this is another example where the observed behavior is completely intentional. The Windows Mobile RAS API does not update the UI (specifically, the signal strength task bar icon) by design. 


Page 1 of 1 (2 items)