當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。