• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Background.BackgroundTaskCompletedEventArgs类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Windows.ApplicationModel.Background.BackgroundTaskCompletedEventArgs的典型用法代码示例。如果您正苦于以下问题:C# BackgroundTaskCompletedEventArgs类的具体用法?C# BackgroundTaskCompletedEventArgs怎么用?C# BackgroundTaskCompletedEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BackgroundTaskCompletedEventArgs类属于Windows.ApplicationModel.Background命名空间,在下文中一共展示了BackgroundTaskCompletedEventArgs类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: OnCompleted

 private void OnCompleted(IBackgroundTaskRegistration task, BackgroundTaskCompletedEventArgs args)
 {
     ShellToast toast = new ShellToast();
     toast.Title = "Sample Application";
     toast.Content = "Background Task Complete";
     toast.Show();
 }
开发者ID:vinayganesh,项目名称:Wp8.1BackgroundTask,代码行数:7,代码来源:RegisterBackgroundTask.cs


示例2: Task_Completed

 void Task_Completed(BackgroundTaskRegistration sender, BackgroundTaskCompletedEventArgs args)
 {
     if (deferral != null)
     {
         deferral.Complete();
     }
 }
开发者ID:poumason,项目名称:DotblogsSampleCode,代码行数:7,代码来源:BackgroundAudioTask.cs


示例3: OnBackgroundTaskCompleted

		private void OnBackgroundTaskCompleted(IBackgroundTaskRegistration task, BackgroundTaskCompletedEventArgs args)
		{
			UpdateLastRunTime();
		}
开发者ID:robledop,项目名称:Demos-20484,代码行数:4,代码来源:MainPage.xaml.cs


示例4: TaskCompleted

 /// <summary>
 /// Indicate that the background task is completed.
 /// </summary>       
 void TaskCompleted(BackgroundTaskRegistration sender, BackgroundTaskCompletedEventArgs args)
 {
     Debug.WriteLine("MyBackgroundAudioTask " + sender.TaskId + " Completed...");
     deferral.Complete();
 }
开发者ID:justijndepover,项目名称:Soundcloudplus,代码行数:8,代码来源:BackgroundAudioTask.cs


示例5: OnCompleted

 /// <summary>
 /// Handle background task completion.
 /// </summary>
 /// <param name="task">The task that is reporting completion.</param>
 /// <param name="e">Arguments of the completion report.</param>
 private void OnCompleted(IBackgroundTaskRegistration task, BackgroundTaskCompletedEventArgs args)
 {
     UpdateUI();
 }
开发者ID:huoxudong125,项目名称:Windows-universal-samples,代码行数:9,代码来源:Scenario3_ServicingCompleteTask.xaml.cs


示例6: OnSyncWithDeviceCompleted

        /// <summary>
        /// Reopen the device after the background task is done syncing. Notify the UI of how many bytes we wrote to the device.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private async void OnSyncWithDeviceCompleted(BackgroundTaskRegistration sender, BackgroundTaskCompletedEventArgs args)
        {
            // Exception may be thrown if an error occurs during running the background task
            args.CheckResult();

            await rootPage.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                new DispatchedHandler(async () =>
                {
                    // Reopen the device once the background task is completed
                    await EventHandlerForDevice.Current.OpenDeviceAsync(syncDeviceInformation, syncDeviceSelector);

                    syncDeviceInformation = null;
                    syncDeviceSelector = null;

                    var taskCompleteStatus = (String)ApplicationData.Current.LocalSettings.Values[LocalSettingKeys.SyncBackgroundTaskStatus];

                    if (taskCompleteStatus == SyncBackgroundTaskInformation.TaskCompleted)
                    {
                        UInt32 totalBytesWritten = (UInt32)ApplicationData.Current.LocalSettings.Values[LocalSettingKeys.SyncBackgroundTaskResult];

                        rootPage.NotifyUser("Sync: Wrote " + totalBytesWritten.ToString() + " bytes to the device", NotifyType.StatusMessage);
                    }
                    else if (taskCompleteStatus == SyncBackgroundTaskInformation.TaskCanceled)
                    {
                        rootPage.NotifyUser("Syncing was canceled", NotifyType.StatusMessage);
                    }

                    // Remove all local setting values
                    ApplicationData.Current.LocalSettings.Values.Clear();

                    isSyncing = false;

                    UpdateButtonStates();
                }));

            // Unregister the background task and let the remaining task finish until completion
            if (backgroundSyncTaskRegistration != null)
            {
                backgroundSyncTaskRegistration.Unregister(false);
            }
        }
开发者ID:mbin,项目名称:Win81App,代码行数:46,代码来源:Scenario7_SyncDevice.xaml.cs


示例7: OnTaskCompleted

 private async void OnTaskCompleted(BackgroundTaskRegistration task, BackgroundTaskCompletedEventArgs args)
 {
     await rootPage.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         rootPage.NotifyUser("Background task completed", NotifyType.StatusMessage);
     });
 }
开发者ID:RasmusTG,项目名称:Windows-universal-samples,代码行数:7,代码来源:Scenario3_BackgroundDeviceWatcher.xaml.cs


示例8: OnCompleted

 /// <summary>
 /// This is the event handler for background task completion.
 /// </summary>
 /// <param name="task">The task that is reporting completion.</param>
 /// <param name="args">The completion report arguments.</param>
 private void OnCompleted(IBackgroundTaskRegistration task, BackgroundTaskCompletedEventArgs args)
 {
     string status = "Completed";
     try
     {
         args.CheckResult();
     }
     catch (Exception e)
     {
         status = e.Message;
     }
     UpdateUIAsync(status);
 }
开发者ID:C-C-D-I,项目名称:Windows-universal-samples,代码行数:18,代码来源:Scenario4_BackgroundProximitySensor.xaml.cs


示例9: OnCompleted

        async private void OnCompleted(IBackgroundTaskRegistration sender, BackgroundTaskCompletedEventArgs e)
        {
            if (sender != null)
            {
                // Update the UI with progress reported by the background task
                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    try
                    {
                        // If the background task threw an exception, display the exception in
                        // the error text box.
                        e.CheckResult();

                        // Update the UI with the completion status of the background task
                        // The Run method of the background task sets this status. 
                        var settings = ApplicationData.Current.LocalSettings;
                        if (settings.Values["Status"] != null)
                        {
                            rootPage.NotifyUser(settings.Values["Status"].ToString(), NotifyType.StatusMessage);
                        }

                        // Extract and display Latitude
                        if (settings.Values["Latitude"] != null)
                        {
                            ScenarioOutput_Latitude.Text = settings.Values["Latitude"].ToString();
                        }
                        else
                        {
                            ScenarioOutput_Latitude.Text = "No data";
                        }

                        // Extract and display Longitude
                        if (settings.Values["Longitude"] != null)
                        {
                            ScenarioOutput_Longitude.Text = settings.Values["Longitude"].ToString();
                        }
                        else
                        {
                            ScenarioOutput_Longitude.Text = "No data";
                        }

                        // Extract and display Accuracy
                        if (settings.Values["Accuracy"] != null)
                        {
                            ScenarioOutput_Accuracy.Text = settings.Values["Accuracy"].ToString();
                        }
                        else
                        {
                            ScenarioOutput_Accuracy.Text = "No data";
                        }
                    }
                    catch (Exception ex)
                    {
                        // The background task had an error
                        rootPage.NotifyUser(ex.ToString(), NotifyType.ErrorMessage);
                    }
                });
            }
        }
开发者ID:trilok567,项目名称:Windows-Phone,代码行数:59,代码来源:Scenario3_BackgroundTask.xaml.cs


示例10: OnCompleted

    private void OnCompleted( IBackgroundTaskRegistration sender, BackgroundTaskCompletedEventArgs e )
    {

      if( sender != null )
      {
        // If the background task threw an exception, display the exception in
        // the error text box.
        e.CheckResult();

        LocationChanged();

        // if( settings.Values[ "Longitude" ] != null )
        // if( settings.Values[ "Accuracy" ] != null )
      }
    }
开发者ID:Georotzen,项目名称:.NET-SDK-1,代码行数:15,代码来源:Win8LocationTrackerEngine.cs


示例11: OnCompleted

        private async void OnCompleted(IBackgroundTaskRegistration sender, BackgroundTaskCompletedEventArgs e)
        {
            if (sender != null)
            {
                // Update the UI with progress reported by the background task
                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    try
                    {
                        // If the background task threw an exception, display the exception in the
                        // error text box.
                        e.CheckResult();

                        // Update the UI with the completion status of the background task The Run
                        // method of the background task sets this status.
                        var settings = ApplicationData.Current.LocalSettings;
                        if (settings.Values["Status"] != null)
                        {
                            Status.Text = settings.Values["Status"].ToString();
                        }

                        // Extract and display location data set by the background task if not null
                        MobilePosition_Latitude.Text = (settings.Values["Latitude"] == null) ? "No data" : settings.Values["Latitude"].ToString();
                        MobilePosition_Longitude.Text = (settings.Values["Longitude"] == null) ? "No data" : settings.Values["Longitude"].ToString();
                        MobilePosition_Accuracy.Text = (settings.Values["Accuracy"] == null) ? "No data" : settings.Values["Accuracy"].ToString();
                    }
                    catch (Exception ex)
                    {
                        // The background task had an error
                        Status.Text = ex.ToString();
                    }
                });
            }
        }
开发者ID:phabrys,项目名称:Domojee,代码行数:34,代码来源:SettingsPage.xaml.cs


示例12: Taskcompleted

 private void Taskcompleted(BackgroundTaskRegistration sender, BackgroundTaskCompletedEventArgs args)
 {
     BackgroundMediaPlayer.Shutdown();
     _deferral.Complete();
 }
开发者ID:se-bastiaan,项目名称:TVNL-WindowsPhone,代码行数:5,代码来源:BackgroundAudioTask.cs


示例13: OnSyncWithDeviceCompleted

        /// <summary>
        /// Reopen the device after the background task is done syncing. Notify the UI of how many bytes we wrote to the device.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private async void OnSyncWithDeviceCompleted(BackgroundTaskRegistration sender, BackgroundTaskCompletedEventArgs args)
        {
            isSyncing = false;

            // Exception may be thrown if an error occurs during running the background task
            args.CheckResult();

            await rootPage.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                new DispatchedHandler(async () =>
                {
                    // Reopen the device once the background task is completed
                    // Don't attempt to reconnect if the device failed to connect
                    var isDeviceSuccessfullyConnected = await EventHandlerForDevice.Current.OpenDeviceAsync(syncDeviceInformation, syncDeviceSelector);

                    if (!isDeviceSuccessfullyConnected)
                    {
                        EventHandlerForDevice.Current.IsEnabledAutoReconnect = false;
                    }

                    syncDeviceInformation = null;
                    syncDeviceSelector = null;

                    // Since we are navigating away, don't touch the UI; we don't care what the output/result of the background task is
                    if (!navigatedAway)
                    {
                        var taskCompleteStatus = (String)ApplicationData.Current.LocalSettings.Values[LocalSettingKeys.SyncBackgroundTaskStatus];

                        if (taskCompleteStatus == SyncBackgroundTaskInformation.TaskCompleted)
                        {
                            UInt32 totalBytesWritten = (UInt32)ApplicationData.Current.LocalSettings.Values[LocalSettingKeys.SyncBackgroundTaskResult];

                            // Set the progress bar to be completely filled in case the progress was not updated (this can happen if the app is suspended)
                            SyncProgressBar.Value = 100;

                            rootPage.NotifyUser("Sync: Wrote " + totalBytesWritten.ToString() + " bytes to the device", NotifyType.StatusMessage);
                        }
                        else if (taskCompleteStatus == SyncBackgroundTaskInformation.TaskCanceled)
                        {
                            // Reset the progress bar in case the progress was not updated (this can happen if the app is suspended)
                            SyncProgressBar.Value = 0;

                            rootPage.NotifyUser("Syncing was canceled", NotifyType.StatusMessage);
                        }

                        UpdateButtonStates();
                    }

                    // Remove all local setting values
                    ApplicationData.Current.LocalSettings.Values.Clear();
                }));

            // Unregister the background task and let the remaining task finish until completion
            if (backgroundSyncTaskRegistration != null)
            {
                backgroundSyncTaskRegistration.Unregister(false);
            }
        }
开发者ID:ChSchmidt81,项目名称:Windows-universal-samples,代码行数:62,代码来源:Scenario7_SyncDevice.xaml.cs


示例14: Mytask_Completed

 private async void Mytask_Completed(BackgroundTaskRegistration sender, BackgroundTaskCompletedEventArgs args)
 {
     // Background task has completed - refresh our data
     await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(
         CoreDispatcherPriority.Normal, 
         async () => await LoadRuntimeDataAsync()
         );
 }
开发者ID:h82258652,项目名称:Samples,代码行数:8,代码来源:MainPageViewModel.cs


示例15: RegistrationCompleted

 private void RegistrationCompleted(BackgroundTaskRegistration sender, BackgroundTaskCompletedEventArgs args)
 {
     ApplicationDataContainer container = ApplicationData.Current.LocalSettings;
     try
     {
         var content = container.Values["RawMessage"].ToString();
         if (content != null)
         {
             ToastMessage message = JsonConvert.DeserializeObject<ToastMessage>(content);
             ToastHelper.DisplayTextToast(ToastTemplateType.ToastImageAndText01, message.FromId, message.Content, message.FromPicture);
         }
     }
     catch (Exception ex)
     {
         ex.ToString();
     }
 }
开发者ID:babilavena,项目名称:Chat-App,代码行数:17,代码来源:App.xaml.cs


示例16: OnCompleted

 /// <summary>
 /// Called when background task defferal is completed.  This can happen for a number of reasons (both expected and unexpected).  
 /// IF this is expected, we'll notify the user.  If it's not, we'll show that this is an error.  Finally, clean up the connection by calling Disconnect().
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="args"></param>
 private async void OnCompleted(BackgroundTaskRegistration sender, BackgroundTaskCompletedEventArgs args)
 {
     var settings = ApplicationData.Current.LocalSettings;
     if (settings.Values.ContainsKey("TaskCancelationReason"))
     {
         await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
         {
             statusTextBlock.Text = "ERROR: Task cancelled unexpectedly - reason: " + settings.Values["TaskCancelationReason"].ToString();
         });
     }
     else
     {
         await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
         {
             statusTextBlock.Text = "STATUS: Background task completed";
         });
     }
     try
     {
         args.CheckResult();
     }
     catch (Exception ex)
     {
         throw;
         //rootPage.NotifyUser(ex.Message, NotifyType.ErrorMessage);
     }
     Disconnect();
 }
开发者ID:GauravC12,项目名称:Windows10BackgroundBluetoothSample,代码行数:34,代码来源:MainPage.xaml.cs


示例17: liveTileUpdater_BackgroundTaskCompleted

 void liveTileUpdater_BackgroundTaskCompleted(BackgroundTaskRegistration sender, BackgroundTaskCompletedEventArgs args)
 {
     DispatchUpdateUI();
 }
开发者ID:clarkezone,项目名称:Win2D,代码行数:4,代码来源:BackgroundTaskExample.xaml.cs


示例18: OnBackgroundTaskCompleted

        /// <summary>
        /// Background task completion handler. When authenticating through the foreground app, this triggers the authentication flow if the app is currently running.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public async void OnBackgroundTaskCompleted(IBackgroundTaskRegistration sender, BackgroundTaskCompletedEventArgs e)
        {
            // Update the UI with progress reported by the background task.
            await coreDispatcher.RunAsync(CoreDispatcherPriority.Normal,
                                      new DispatchedHandler(() =>
                                      {
                                          try
                                          {
                                              if ((sender != null) && (e != null))
                                              {
                                                  // If the background task threw an exception, display the exception in the error text box.
                                                  e.CheckResult();

                                                  // Update the UI with the completion status of the background task
                                                  // The Run method of the background task sets this status.
                                                  if (sender.Name == BackgroundTaskName)
                                                  {
                                                      rootPage.NotifyUser("Background task completed", NotifyType.StatusMessage);

                                                      // Signal callback for foreground authentication
                                                      if (!ConfigStore.AuthenticateThroughBackgroundTask && ForegroundAuthenticationCallback != null)
                                                      {
                                                          ForegroundAuthenticationCallback(this, null);
                                                      }
                                                  }
                                              }
                                          }
                                          catch (Exception ex)
                                          {
                                              rootPage.NotifyUser(ex.ToString(), NotifyType.ErrorMessage);
                                          }
                                      }));
        }
开发者ID:mbin,项目名称:Win81App,代码行数:38,代码来源:ScenarioCommon.cs


示例19: OnCompleted

        /// <summary>
        /// Handle background task completion.
        /// </summary>
        /// <param name="task">The task that is reporting completion.</param>
        /// <param name="e">Arguments of the completion report.</param>
        private async void OnCompleted(IBackgroundTaskRegistration task, BackgroundTaskCompletedEventArgs args)
        {
            ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings;

            Object profile = localSettings.Values["InternetProfile"];
            Object adapter = localSettings.Values["NetworkAdapterId"];

            Object hasNewConnectionCost = localSettings.Values["HasNewConnectionCost"];
            Object hasNewDomainConnectivityLevel = localSettings.Values["HasNewDomainConnectivityLevel"];
            Object hasNewHostNameList = localSettings.Values["HasNewHostNameList"];
            Object hasNewInternetConnectionProfile = localSettings.Values["HasNewInternetConnectionProfile"];
            Object hasNewNetworkConnectivityLevel = localSettings.Values["HasNewNetworkConnectivityLevel"];

            await NetworkStatusWithInternetPresentDispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                string outputText = string.Empty;

                if ((profile != null) && (adapter != null))
                {
                    //If internet profile has changed, display the new internet profile
                    if ((string.Equals(profile.ToString(), internetProfile, StringComparison.Ordinal) == false) ||
                            (string.Equals(adapter.ToString(), networkAdapter, StringComparison.Ordinal) == false))
                    {
                        internetProfile = profile.ToString();
                        networkAdapter = adapter.ToString();
                        outputText += "Internet Profile changed\n" + "=================\n" + "Current Internet Profile : " + internetProfile + "\n\n";

                        if (hasNewConnectionCost != null)
                        {
                            outputText += hasNewConnectionCost.ToString() + "\n";
                        }
                        if (hasNewDomainConnectivityLevel != null)
                        {
                            outputText += hasNewDomainConnectivityLevel.ToString() + "\n";
                        }
                        if (hasNewHostNameList != null)
                        {
                            outputText += hasNewHostNameList.ToString() + "\n";
                        }
                        if (hasNewInternetConnectionProfile != null)
                        {
                            outputText += hasNewInternetConnectionProfile.ToString() + "\n";
                        }
                        if (hasNewNetworkConnectivityLevel != null)
                        {
                            outputText += hasNewNetworkConnectivityLevel.ToString() + "\n";
                        }

                        rootPage.NotifyUser(outputText, NotifyType.StatusMessage);
                    }
                }
            });
        }
开发者ID:badreddine-dlaila,项目名称:Windows-8.1-Universal-App,代码行数:58,代码来源:Scenario1_NetworkStatusWithInternetPresent.xaml.cs


示例20: OnBackgroundTaskCompleted

        private void OnBackgroundTaskCompleted(BackgroundTaskRegistration sender, BackgroundTaskCompletedEventArgs args)
        {
            args.CheckResult(); // TODO: What kind of errors does this report?
            Debug.WriteLine(sender); // BackgroundTaskRegistration
            string instanceIdString = args.InstanceId.ToString();

            if (!ApplicationData.Current.LocalSettings.Values.ContainsKey(instanceIdString))
            {
                // This task didn't schedule a download.
                return;
            }

            Guid transferGuid = (Guid)ApplicationData.Current.LocalSettings.Values[instanceIdString];
            Debug.WriteLine("Background task completed! Last download was {0}", transferGuid);
        }
开发者ID:kiewic,项目名称:Projects,代码行数:15,代码来源:App.xaml.cs



注:本文中的Windows.ApplicationModel.Background.BackgroundTaskCompletedEventArgs类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Background.BackgroundTaskDeferral类代码示例发布时间:2022-05-26
下一篇:
C# Background.BackgroundTaskBuilder类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap