Windows phone 8 how to check network availability

I am developing an application for Windows Phone 8 with C #, and my application should automatically be implemented when the network changes.

So, when Windows Phone suddenly connects to the Internet, I need to take some action, but I really don't know how to check it. I do not want to set a timer, constantly working in the thread, to check this every couple of seconds.

Is there any method (similar to the OnNavigatedTo method) that starts automatically when the phone connects to the Internet?

If so, what is the best and most effective way to implement this?

Thank you for all the advice and your help in advance!

+1
source share
4 answers

All you need is a NetworkAvailabilityChanged Event . You can find all available information in the DeviceNetworkInformation Class .

0
source

use this name

using Microsoft.Phone.Net.NetworkInformation;

  if (NetworkInterface.GetIsNetworkAvailable() == true) { //Do something } else { //Do Something } 
+3
source

Use the Hollywood principle instead of polling:

NetworkInformation.NetworkStatusChanged

0
source

You can check network availability in .Net Framework 2.0 using

 if(System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable()) { //Do your stuffs when network available } else { //Do stuffs when network not available } 

It will return true or false .

0
source

Source: https://habr.com/ru/post/1209883/


All Articles