本文整理汇总了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();
}
示例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();
}
示例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();
}
示例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();
}
示例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");
}
示例6: OnCanceled
private void OnCanceled(IBackgroundTaskInstance taskInstance, BackgroundTaskCancellationReason reason)
{
CommonData.TaskExitReason = reason.ToString();
deferral.Complete();
}
示例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();
}
示例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());
}
示例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");
}
示例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();
}