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


C# BackgroundTaskCancellationReason.ToString方法代码示例

本文整理汇总了C#中BackgroundTaskCancellationReason.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# BackgroundTaskCancellationReason.ToString方法的具体用法?C# BackgroundTaskCancellationReason.ToString怎么用?C# BackgroundTaskCancellationReason.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BackgroundTaskCancellationReason的用法示例。


在下文中一共展示了BackgroundTaskCancellationReason.ToString方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TaskInstance_Canceled

 private void TaskInstance_Canceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
 {
     var properties = new Dictionary<string, string>();
     properties.Add("Reason", reason.ToString());
     StartupTask.WriteTelemetryEvent("AppServicesBackgroundTask_Canceled", properties);
     serviceDeferral.Complete();
 }
开发者ID:farukc,项目名称:internetradio,代码行数:7,代码来源:AppServicesBackgroundTask.cs

示例2: OnCanceled

        /// <summary> 
        /// Called when the background task is canceled by the app or by the system.
        /// </summary> 
        /// <param name="sender"></param>
        /// <param name="reason"></param>
        private void OnCanceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
        {
            ApplicationData.Current.LocalSettings.Values["TaskCancelationReason"] = reason.ToString();
            ApplicationData.Current.LocalSettings.Values["SampleCount"] = _sampleCount;
            ApplicationData.Current.LocalSettings.Values["IsBackgroundTaskActive"] = false;

            // Complete the background task (this raises the OnCompleted event on the corresponding BackgroundTaskRegistration).
            _deferral.Complete();
        }
开发者ID:SoftwareFactoryUPC,项目名称:ProjectTemplates,代码行数:14,代码来源:Scenario1_BackgroundTask.cs

示例3: TaskInstance_Canceled

        private async void TaskInstance_Canceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
        {
            var properties = new Dictionary<string, string>();
            properties.Add("Reason", reason.ToString());
            WriteTelemetryEvent("App_Shutdown", properties);

            await s_radioManager.Dispose();

            deferral.Complete();
        }
开发者ID:farukc,项目名称:internetradio,代码行数:10,代码来源:StartupTask.cs

示例4: OnCanceled

        /// <summary> 
        /// Called when the background task is canceled by the app or by the system.
        /// </summary> 
        /// <param name="sender"></param>
        /// <param name="reason"></param>
        private void OnCanceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
        {
            ApplicationData.Current.LocalSettings.Values["TaskCancelationReason"] = reason.ToString();
            ApplicationData.Current.LocalSettings.Values["SampleCount"] = SampleCount;
            ApplicationData.Current.LocalSettings.Values["IsBackgroundTaskActive"] = false;

            if (null != Accelerometer)
            {
                Accelerometer.ReadingChanged -= new TypedEventHandler<Accelerometer, AccelerometerReadingChangedEventArgs>(ReadingChanged);
                Accelerometer.ReportInterval = 0;
            }

            // Complete the background task (this raises the OnCompleted event on the corresponding BackgroundTaskRegistration).
            Deferral.Complete();
        }
开发者ID:RasmusTG,项目名称:Windows-universal-samples,代码行数:20,代码来源:Scenario1_BackgroundTask.cs

示例5: OnCanceled

 /// <summary>
 /// Handles background task cancellation.
 /// </summary>
 /// <param name="sender">The background task instance being cancelled.</param>
 /// <param name="reason">The cancellation reason.</param>
 private void OnCanceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
 {
     var settings = ApplicationData.Current.LocalSettings;
     Debug.WriteLine("Background " + sender.Task.Name + " Cancel Requested...");
     settings.Values["TaskStatus"] = reason.ToString() + " at " + DateTime.Now.ToString("u");
 }
开发者ID:C-C-D-I,项目名称:Windows-universal-samples,代码行数:11,代码来源:ProximitySensorBackgroundTask.cs

示例6: OnCanceled

 private void OnCanceled(IBackgroundTaskInstance taskInstance, BackgroundTaskCancellationReason reason)
 {
     CommonData.TaskExitReason = reason.ToString(); 
     deferral.Complete();
 }
开发者ID:caesarjiang,项目名称:BLETestStuffWindows,代码行数:5,代码来源:BluetoothWatcherBackgroundTask.cs

示例7: OnCanceled

        private void OnCanceled(IBackgroundTaskInstance taskInstance, BackgroundTaskCancellationReason reason)
        {
            cancelReason = reason;
            cancelRequested = true;

            ApplicationData.Current.LocalSettings.Values["TaskCancelationReason"] = cancelReason.ToString();
            ApplicationData.Current.LocalSettings.Values["IsBackgroundTaskActive"] = false;
            ApplicationData.Current.LocalSettings.Values["ReceivedMessage"] = "";
            // Complete the background task (this raises the OnCompleted event on the corresponding BackgroundTaskRegistration). 
            deferral.Complete();
        }
开发者ID:jigartailor1984,项目名称:UWPAppSamples,代码行数:11,代码来源:RfcommServerTask.cs

示例8: OnCanceled

 /// <summary>
 /// Behandelt den Abbruch der Hintergrundaufgabe.
 /// </summary>
 /// <param name="sender">Die Instanz der IBackgroundTask, die das Canceled Event ausgelöst hat.</param>
 /// <param name="reason">Der Grund für den Abbruch.</param>
 private void OnCanceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
 {
     // Mache hier vorest nichts. Nur Fehler loggen.
     Debug.WriteLine("Abort RawNotification background task. Sender: " + sender.ToString() + ", Reason: " + reason.ToString());
 }
开发者ID:ulm-university-news,项目名称:UlmUniversityNewsWindowsApp,代码行数:10,代码来源:PushNotificationManager.cs

示例9: OnCanceled

 /// <summary>
 /// Handles background task cancellation.
 /// </summary>
 /// <param name="sender">The background task instance being cancelled.</param>
 /// <param name="reason">The cancellation reason.</param>
 private void OnCanceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
 {
     var settings = ApplicationData.Current.LocalSettings;
     settings.Values["TaskStatus"] = reason.ToString() + " at " + DateTime.Now.ToString("u");
 }
开发者ID:COMIsLove,项目名称:Windows-universal-samples,代码行数:10,代码来源:PedometerBackgroundTask.cs

示例10: HandleTaskInstanceCanceled

        private void HandleTaskInstanceCanceled(IBackgroundTaskInstance taskInstance, BackgroundTaskCancellationReason reason)
        {
            PlayQueueManager.Current.Disconnect();

            TileUpdateManager.CreateTileUpdaterForApplication("App").Clear();

            Logger.Current.Init(LogType.AudioFunction);

            Logger.Current.Log(new CallerInfo(), LogLevel.Info, "AudioPlayer Background Task Completed id:{0} reason:{1}", taskInstance.Task.TaskId, reason.ToString());

            ApplicationSettings.PutSettingsValue(ApplicationSettings.IS_BACKGROUND_PROCESS_ACTIVE, false);

            if (ApplicationSettings.GetSettingsValue<bool>(ApplicationSettings.IS_FOREGROUND_PROCESS_ACTIVE, false))
            {
                PlayQueueManager.Current.SendMessageToForeground(PlayQueueConstantBGMessageId.BackgroundEnded);
            }

            backgroundTaskState = BackgroundTaskState.Stopped;

            PlayQueueManager.Current.TrackChanged -= HandlePlayQueueTrackChanged;

            BackgroundMediaPlayer.Current.CurrentStateChanged -= HandleBackgroundMediaPlayerCurrentStateChanged;
            taskInstance.Task.Completed -= HandleTaskInstanceTaskCompleted;
            taskInstance.Canceled -= HandleTaskInstanceCanceled;

            BackgroundMediaPlayer.Shutdown();

            Logger.Current.Flush();

            backgroundTaskDefferal.Complete();
        }
开发者ID:jevonsflash,项目名称:ProjectMato,代码行数:31,代码来源:AudioPlayer.cs


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