本文整理汇总了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...");
}
示例2: TaskInstance_Canceled
private void TaskInstance_Canceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
{
_clock.Dispose();
_timer2.Cancel();
_timer3.Cancel();
_deferral.Complete();
}
示例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...");
}
示例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...");
}
示例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();
}
示例6: TaskInstance_Canceled
private void TaskInstance_Canceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
{
if (this.deferral != null)
{
this.deferral.Complete();
}
}
示例7: OnCanceled
//
// Handles background task cancellation.
//
private void OnCanceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
{
//
// Indicate that the background task is canceled.
//
}
示例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();
}
示例9: OnCanceled
private void OnCanceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
{
if (_cts != null)
{
_cts.Cancel();
_cts = null;
}
}
示例10: OnCanceled
private void OnCanceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
{
//
// Indicate that the background task is canceled.
//
_cancelRequested = true;
_cancelReason = reason;
}
示例11: OnTaskCanceled
private void OnTaskCanceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
{
if (this.serviceDeferral != null)
{
//Complete the service deferral
this.serviceDeferral.Complete();
}
}
示例12: canceled
private void canceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
{
deferral.Complete();
deferral = null;
timer.Tick -= timerTick;
timer = null;
controller = null;
}
示例13: TaskInstance_Canceled
private void TaskInstance_Canceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
{
if (mDeferral != null)
{
mDeferral.Complete();
}
CurrentOperation.PhoneCallTaskDeferral = null;
}
示例14: TaskInstance_Canceled
private void TaskInstance_Canceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
{
BackgroundMediaPlayer.Shutdown();
if (deferral != null)
{
deferral.Complete();
}
}
示例15: TaskInstance_Canceled
private void TaskInstance_Canceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
{
if (_deferral != null)
{
_deferral.Complete();
}
Current.RTCTaskDeferral = null;
}