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

C# BackgroundTaskCancellationReason类代码示例

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

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



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


示例16: OnTaskCanceled

 private void OnTaskCanceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
 {
     System.Diagnostics.Debug.WriteLine("Task cancelled, clean up");
     if (this.serviceDeferral != null)
     {
         //Complete the service deferral
         this.serviceDeferral.Complete();
     }
 }
开发者ID:Pinoplast,项目名称:WinDevWorkshop,代码行数:9,代码来源:HolVoiceCommandService.cs


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


示例18: OnTaskCanceled

 private void OnTaskCanceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
 {
     Debug.WriteLine("App service closed due to an unexpected failure; Cleaning up");
     if (this.serviceDeferral != null)
     {
         //Complete the service deferral
         this.serviceDeferral.Complete();
     }
 }
开发者ID:nicol3ta,项目名称:alterna,代码行数:9,代码来源:AlternaService.cs


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


示例20: OnCanceled

        //
        // Handles background task cancellation.
        //
        private void OnCanceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
        {
            //
            // Indicate that the background task is canceled.
            //
            var settings = Windows.Storage.ApplicationData.Current.LocalSettings;
            settings.Values[sender.Task.TaskId.ToString()] = "Canceled";

            Debug.WriteLine("Background " + sender.Task.Name + " Cancel Requested...");
        }
开发者ID:oldnewthing,项目名称:old-Windows8-samples,代码行数:13,代码来源:SampleSmsBackgroundTask.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# BackgroundTransferRequest类代码示例发布时间:2022-05-24
下一篇:
C# BackgroundAudioPlayer类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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