locked
is there any other system event on internet avaliable without using backgournd task? RRS feed

  • Question

  • is there any other system event on internet avaliable without using backgournd task?

    i known that the event is exist, but it is needed to use backgournd task.

    Thursday, November 20, 2014 12:53 AM

Answers

  • Hi,

    For WP 8.1 RT app, please consider using Windows.Networking.Connectivity.NetworkInformation class, it has NetworkStatusChanged event which will occur when the network status changes for a connection: http://msdn.microsoft.com/en-us/library/windows/apps/windows.networking.connectivity.networkinformation.networkstatuschanged.aspx

    Here is my sample:

    <TextBlock x:Name="tb1" FontSize="40" Text="NULL" />

    public MainPage()
    {
                this.InitializeComponent();
    
                this.NavigationCacheMode = NavigationCacheMode.Required;
    
                NetworkInformation.NetworkStatusChanged += NetworkInformation_NetworkStatusChanged;
    }
    
    async void NetworkInformation_NetworkStatusChanged(object sender)
    {
                try
                {
                    var coninfo = NetworkInformation.GetInternetConnectionProfile();
                    if (coninfo != null)
                        await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => {
                            tb1.Text = coninfo.ProfileName;
                        });
                        
                }
                catch(Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                }
    }

    For WP SL 8.0 or 8.1 app, Microsoft.Phone.Net.NetworkInformation.DeviceNetworkInformation class can accomplish your requirement: http://msdn.microsoft.com/en-us/library/windows/apps/microsoft.phone.net.networkinformation.devicenetworkinformation(v=vs.105).aspx


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, November 20, 2014 10:34 AM