Skip to content

Instantly share code, notes, and snippets.

@mushfiqweb
Created May 26, 2017 12:43
Show Gist options
  • Select an option

  • Save mushfiqweb/4e235d4c577e84d99c33acafc11295a7 to your computer and use it in GitHub Desktop.

Select an option

Save mushfiqweb/4e235d4c577e84d99c33acafc11295a7 to your computer and use it in GitHub Desktop.
// register for network status change notifications
networkStatusCallback = new NetworkStatusChangedEventHandler(OnNetworkStatusChange);
if (!registeredNetworkStatusNotif)
{
NetworkInformation.NetworkStatusChanged += networkStatusCallback;
registeredNetworkStatusNotif = true;
}
async void OnNetworkStatusChange(object sender)
{
// get the ConnectionProfile that is currently used to connect to the Internet
ConnectionProfile InternetConnectionProfile = NetworkInformation.GetInternetConnectionProfile();
if (InternetConnectionProfile == null)
{
await _cd.RunAsync(CoreDispatcherPriority.Normal, () =>
{
rootPage.NotifyUser("Not connected to Internet\n", NotifyType.StatusMessage);
});
}
else
{
connectionProfileInfo = GetConnectionProfile(InternetConnectionProfile);
await _cd.RunAsync(CoreDispatcherPriority.Normal, () =>
{
rootPage.NotifyUser(connectionProfileInfo, NotifyType.StatusMessage);
});
}
internetProfileInfo = "";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment