Exemplo n.º 1
0
        private void RegisterButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var connectionProfile = NetworkInformation.GetInternetConnectionProfile();
                if (connectionProfile != null)
                {
                    internetProfile = connectionProfile.ProfileName;
                    var networkAdapterInfo = connectionProfile.NetworkAdapter;
                    if (networkAdapterInfo != null)
                    {
                        networkAdapterId = networkAdapterInfo.NetworkAdapterId.ToString();
                    }
                    else
                    {
                        networkAdapterId = "Not network adapter id";
                    }
                }
                else
                {
                    internetProfile  = "Not contected to Internet";
                    networkAdapterId = "Not network adapter id";
                }
                var task = BackgroundTaskSample.RegisterBackgroundTask(BackgroundTaskSample.SampleBackgroundTaskEntryPoint,
                                                                       BackgroundTaskSample.SampleBackgroundWithConditionName,
                                                                       new SystemTrigger(SystemTriggerType.NetworkStateChange, false), null);

                UpdateButton(true);
            }
            catch (Exception)
            {
            }
        }
Exemplo n.º 2
0
 private void unregisterButton_Click(object sender, RoutedEventArgs e)
 {
     BackgroundTaskSample.UnregisterBackgroundTasks(BackgroundTaskSample.SampleBackgroundWithConditionName);
     UpdateButton(false);
 }