当前位置: 首页>>代码示例>>C#>>正文


C# Background.BackgroundTaskCompletedEventArgs类代码示例

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


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


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