當前位置: 首頁>>代碼示例>>C#>>正文


C# BackgroundTaskCancellationReason類代碼示例

本文整理匯總了C#中BackgroundTaskCancellationReason的典型用法代碼示例。如果您正苦於以下問題:C# BackgroundTaskCancellationReason類的具體用法?C# BackgroundTaskCancellationReason怎麽用?C# BackgroundTaskCancellationReason使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


BackgroundTaskCancellationReason類屬於命名空間,在下文中一共展示了BackgroundTaskCancellationReason類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: OnCanceled

        private void OnCanceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
        {
            _cancelRequested = true;
            _cancelReason = reason;

            Debug.WriteLine($"Background '{sender.Task.Name}' Cancel Requested...");
        }
開發者ID:mohamedmansour,項目名稱:MyElectricCar,代碼行數:7,代碼來源:MyElectricCarMonitorTask.cs

示例2: TaskInstance_Canceled

 private void TaskInstance_Canceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
 {
     _clock.Dispose();
     _timer2.Cancel();
     _timer3.Cancel();
     _deferral.Complete();
 }
開發者ID:bschapendonk,項目名稱:sensorclock,代碼行數:7,代碼來源:StartupTask.cs

示例3: OnCanceled

 //
 // Handles background task cancellation.
 //
 private void OnCanceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
 {
     //
     // Indicate that the background task is canceled.
     //
     Debug.WriteLine("Background " + sender.Task.Name + " Cancel Requested...");
 }
開發者ID:ckc,項目名稱:WinApp,代碼行數:10,代碼來源:BackgroundTask.cs

示例4: OnCanceled

        /// <summary>
        ///     Handles background task cancellation. Task cancellation happens due to:
        ///     1. Another Media app comes into foreground and starts playing music
        ///     2. Resource pressure. Your task is consuming more CPU and memory than allowed.
        ///     In either case, save state so that if foreground app resumes it can know where to start.
        /// </summary>
        private void OnCanceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
        {
            // You get some time here to save your state before process and resources are reclaimed
            Debug.WriteLine("MyBackgroundAudioTask " + sender.Task.TaskId + " Cancel Requested...");
            try
            {
                // immediately set not running
                TaskStarted.Reset();

                // Dispose
                _playerWrapper.Dispose();
                _smtcWrapper.Dispose();
                _foregroundMessenger.Dispose();

                // shutdown media pipeline
                BackgroundMediaPlayer.Shutdown();
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
            }

            _settingsUtility.Write(ApplicationSettingsConstants.BackgroundTaskState,
                BackgroundTaskState.Canceled);

            _deferral.Complete(); // signals task completion. 
            Debug.WriteLine("MyBackgroundAudioTask Cancel complete...");
        }
開發者ID:haroldma,項目名稱:Audiotica,代碼行數:34,代碼來源:BackgroundAudioTask.cs

示例5: TaskInstance_Canceled

        private void TaskInstance_Canceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
        {
            this.SendToForeground(CommunicationConstants.BackgroundTaskStopped);

            try
            {
                ApplicationSettings.BackgroundTaskResumeSongTime.Save(BackgroundMediaPlayer.Current.Position.TotalSeconds);
                /*
                //save state
                ApplicationSettingsHelper.SaveSettingsValue(Constants.CurrentTrack, Playlist.CurrentTrackName);
                ApplicationSettingsHelper.SaveSettingsValue(Constants.Position, BackgroundMediaPlayer.Current.Position.ToString());
                ApplicationSettingsHelper.SaveSettingsValue(Constants.BackgroundTaskState, Constants.BackgroundTaskCancelled);
                ApplicationSettingsHelper.SaveSettingsValue(Constants.AppState, Enum.GetName(typeof(ForegroundAppStatus), foregroundAppState));
                backgroundtaskrunning = false;
                //unsubscribe event handlers
                systemmediatransportcontrol.ButtonPressed -= systemmediatransportcontrol_ButtonPressed;
                systemmediatransportcontrol.PropertyChanged -= systemmediatransportcontrol_PropertyChanged;
                Playlist.TrackChanged -= playList_TrackChanged;

                //clear objects task cancellation can happen uninterrupted
                playlistManager.ClearPlaylist();
                playlistManager = null;
                 */
                this.mediaControls.ButtonPressed -= mediaControls_ButtonPressed;
                playlistManager = null;

                BackgroundMediaPlayer.Shutdown(); // shutdown media pipeline
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
            }
            if (_deferral != null)
                _deferral.Complete();
        }
開發者ID:JulianMH,項目名稱:music-3,代碼行數:35,代碼來源:AudioPlayer.cs

示例6: TaskInstance_Canceled

 private void TaskInstance_Canceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
 {
     if (this.deferral != null)
     {
         this.deferral.Complete();
     }
 }
開發者ID:muneneevans,項目名稱:blog,代碼行數:7,代碼來源:Grocery.cs

示例7: OnCanceled

        //
        // Handles background task cancellation.
        //
        private void OnCanceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
        {
            //
            // Indicate that the background task is canceled.
            //

        }
開發者ID:narganapathy,項目名稱:Hindu-Calendar,代碼行數:10,代碼來源:TimerTriggerTask.cs

示例8: 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

示例9: OnCanceled

 private void OnCanceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
 {
     if (_cts != null)
     {
         _cts.Cancel();
         _cts = null;
     }
 }
開發者ID:phabrys,項目名稱:Domojee,代碼行數:8,代碼來源:LocationBackgroundTask.cs

示例10: OnCanceled

 private void OnCanceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
 {
     //
     // Indicate that the background task is canceled.
     //
     _cancelRequested = true;
     _cancelReason = reason;
 }
開發者ID:JamborYao,項目名稱:UwpStart,代碼行數:8,代碼來源:ToastBackgroundTask.cs

示例11: OnTaskCanceled

 private void OnTaskCanceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
 {
     if (this.serviceDeferral != null)
     {
         //Complete the service deferral
         this.serviceDeferral.Complete();
     }
 }
開發者ID:webbgr,項目名稱:Build2015,代碼行數:8,代碼來源:TrackingService.cs

示例12: canceled

		private void canceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
		{
			deferral.Complete();
			deferral = null;
			timer.Tick -= timerTick;
			timer = null;
			controller = null;
		}
開發者ID:holtsoftware,項目名稱:House,代碼行數:8,代碼來源:StartupTask.cs

示例13: TaskInstance_Canceled

 private void TaskInstance_Canceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
 {
     if (mDeferral != null)
     {
         mDeferral.Complete();
     }
     CurrentOperation.PhoneCallTaskDeferral = null;
 }
開發者ID:VTCSecureLLC,項目名稱:mediastreamer2,代碼行數:8,代碼來源:PhoneCallTask.cs

示例14: TaskInstance_Canceled

 private void TaskInstance_Canceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
 {
     BackgroundMediaPlayer.Shutdown();
     if (deferral != null)
     {
         deferral.Complete();
     }
 }
開發者ID:poumason,項目名稱:DotblogsSampleCode,代碼行數:8,代碼來源:BackgroundAudioTask.cs

示例15: TaskInstance_Canceled

        private void TaskInstance_Canceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
        {
            if (_deferral != null)
            {
                _deferral.Complete();
            }

            Current.RTCTaskDeferral = null;
        }
開發者ID:C-C-D-I,項目名稱:Windows-universal-samples,代碼行數:9,代碼來源:CallRtcTask.cs


注:本文中的BackgroundTaskCancellationReason類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。