locked
Window mobile 6.5.3 development internet connection verification in c# RRS feed

  • Question

  • Hi All,

    Developing a window mobile application 6.5 in c# in vs2008.

    I wanted to share my scenario with experts and wanted to confirm that which scenario would be more feasible for me.

    in my application i am storing user inputs in local database when internet is not connected and when ever internet is get connected i automatically update the server database by web-service.

    Can anybody please tell me how to check that now internet is connected and now i can sync with db server,

    a) should i make any type of scheduler?

    b) should i call the timer type functionality which checks the internet in every few interval of time.'

    Hope you people read my mind please pay Ur valuable thoughts on this..

    Hope to hear from you soon...your help is greatly appreciated.

    Thanks

     

    Thursday, February 10, 2011 7:13 AM

Answers

  •  

    Hi Sanjeev Thakur,

     

    Only I can find is how to know if your device was connect with Internet. You can use this function.

     

    InternetGetConnectedState

     

    But how to automatically get this information, I have no better idea.

     

    I hope my suggestion can help you to solve this problem.

     

    Best regards,

    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Jesse Jiang Wednesday, February 23, 2011 9:40 AM
    Monday, February 14, 2011 8:21 AM
  • 1. Start your application as a background process or service.

    2. Using the State and Notification Broker (SNAPI), have your application listen for some/all of these:

    ////////////////////////////////////////////////////////////////////////////////
    // WiFiStateConnected
    // Gets a value indicating whether Wi-Fi is connected to a network
    #define SN_WIFISTATECONNECTED_ROOT HKEY_LOCAL_MACHINE
    #define SN_WIFISTATECONNECTED_PATH TEXT("System\\State\\Hardware")
    #define SN_WIFISTATECONNECTED_VALUE TEXT("WiFi")
    #define SN_WIFISTATECONNECTED_BITMASK 0x10

    ////////////////////////////////////////////////////////////////////////////////
    // CellNetwork Connected
    // Gets a value indicating what cellular system is used for connection
    #define SN_CELLSYSTEMCONNECTED_ROOT HKEY_LOCAL_MACHINE
    #define SN_CELLSYSTEMCONNECTED_PATH TEXT("System\\State\\Phone")
    #define SN_CELLSYSTEMCONNECTED_VALUE TEXT("Cellular System Connected")

    ////////////////////////////////////////////////////////////////////////////////
    // ConnectionsNetworkCount
    // Gets a value indicating the number of network connections that are currently connected.
    #define SN_CONNECTIONSNETWORKCOUNT_ROOT HKEY_LOCAL_MACHINE
    #define SN_CONNECTIONSNETWORKCOUNT_PATH TEXT("System\\State\\Connections\\Network")
    #define SN_CONNECTIONSNETWORKCOUNT_VALUE TEXT("Count")

    http://msdn.microsoft.com/en-us/library/bb154479.aspx

    3. Try to connect to your server. If you can, then perform your update. if not, then wait for the next SNAPI event.

    • Marked as answer by Jesse Jiang Wednesday, February 23, 2011 9:40 AM
    Monday, February 14, 2011 6:45 PM

All replies

  • Hello Sanju Baba,

    You can check internet connection when your perform below listed operation.

    1) Application started time.

    2) Every operation in your application you can check internet connectivity. (like any button click).

    3) Application close time.

    In that case you can sync your data with server.

    Note : Not required any timer and thread to check internet connection. There is some overhead in application to run Thread and Timer.

     

    Hope it helps.

     


    - Pavan Pareta [MCTS - Windows Mobile 5.0] If you find my post is helpful for you then mark as a answer and vote it.
    Thursday, February 10, 2011 7:43 AM
  • Hey Pava,

     

    thanks for the replies,

    suppose i have installed my application on any device ie - Motorola MC-65 in form of (.cab). so how can i make my application automatically runs when it  synchronized with internet

    i don't want to disturb the user to again run the application when device is connected to the internet.

    i wanted that automatically i fetch the records from local device database.

    basically i wanted to offer the functionality whenever a device is connected to internet it automatically get sych with main server,

     

    Thanks,

     

    Thursday, February 10, 2011 9:57 AM
  •  

    Hi Sanjeev Thakur,

     

    Only I can find is how to know if your device was connect with Internet. You can use this function.

     

    InternetGetConnectedState

     

    But how to automatically get this information, I have no better idea.

     

    I hope my suggestion can help you to solve this problem.

     

    Best regards,

    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Jesse Jiang Wednesday, February 23, 2011 9:40 AM
    Monday, February 14, 2011 8:21 AM
  • 1. Start your application as a background process or service.

    2. Using the State and Notification Broker (SNAPI), have your application listen for some/all of these:

    ////////////////////////////////////////////////////////////////////////////////
    // WiFiStateConnected
    // Gets a value indicating whether Wi-Fi is connected to a network
    #define SN_WIFISTATECONNECTED_ROOT HKEY_LOCAL_MACHINE
    #define SN_WIFISTATECONNECTED_PATH TEXT("System\\State\\Hardware")
    #define SN_WIFISTATECONNECTED_VALUE TEXT("WiFi")
    #define SN_WIFISTATECONNECTED_BITMASK 0x10

    ////////////////////////////////////////////////////////////////////////////////
    // CellNetwork Connected
    // Gets a value indicating what cellular system is used for connection
    #define SN_CELLSYSTEMCONNECTED_ROOT HKEY_LOCAL_MACHINE
    #define SN_CELLSYSTEMCONNECTED_PATH TEXT("System\\State\\Phone")
    #define SN_CELLSYSTEMCONNECTED_VALUE TEXT("Cellular System Connected")

    ////////////////////////////////////////////////////////////////////////////////
    // ConnectionsNetworkCount
    // Gets a value indicating the number of network connections that are currently connected.
    #define SN_CONNECTIONSNETWORKCOUNT_ROOT HKEY_LOCAL_MACHINE
    #define SN_CONNECTIONSNETWORKCOUNT_PATH TEXT("System\\State\\Connections\\Network")
    #define SN_CONNECTIONSNETWORKCOUNT_VALUE TEXT("Count")

    http://msdn.microsoft.com/en-us/library/bb154479.aspx

    3. Try to connect to your server. If you can, then perform your update. if not, then wait for the next SNAPI event.

    • Marked as answer by Jesse Jiang Wednesday, February 23, 2011 9:40 AM
    Monday, February 14, 2011 6:45 PM
  •  

    Hi Sanjeev,

     

    I'm very interested in hearing more about your issue, did you solve your problem?

    If so please share the solution with us and mark the right answers.

    If not please let me know and I will tray to help you find further solutions.

     

    Have a nice day!

    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, February 16, 2011 7:08 AM