本文整理汇总了C#中Windows.ApplicationModel.Background.BackgroundTaskCompletedEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# BackgroundTaskCompletedEventArgs类的具体用法?C# BackgroundTaskCompletedEventArgs怎么用?C# BackgroundTaskCompletedEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BackgroundTaskCompletedEventArgs类属于Windows.ApplicationModel.Background命名空间,在下文中一共展示了BackgroundTaskCompletedEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnCompleted
private void OnCompleted(IBackgroundTaskRegistration task, BackgroundTaskCompletedEventArgs args)
{
ShellToast toast = new ShellToast();
toast.Title = "Sample Application";
toast.Content = "Background Task Complete";
toast.Show();
}
示例2: Task_Completed
void Task_Completed(BackgroundTaskRegistration sender, BackgroundTaskCompletedEventArgs args)
{
if (deferral != null)
{
deferral.Complete();
}
}
示例3: OnBackgroundTaskCompleted
private void OnBackgroundTaskCompleted(IBackgroundTaskRegistration task, BackgroundTaskCompletedEventArgs args)
{
UpdateLastRunTime();
}
示例4: TaskCompleted
/// <summary>
/// Indicate that the background task is completed.
/// </summary>
void TaskCompleted(BackgroundTaskRegistration sender, BackgroundTaskCompletedEventArgs args)
{
Debug.WriteLine("MyBackgroundAudioTask " + sender.TaskId + " Completed...");
deferral.Complete();
}
示例5: OnCompleted
/// <summary>
/// Handle background task completion.
/// </summary>
/// <param name="task">The task that is reporting completion.</param>
/// <param name="e">Arguments of the completion report.</param>
private void OnCompleted(IBackgroundTaskRegistration task, BackgroundTaskCompletedEventArgs args)
{
UpdateUI();
}
开发者ID:huoxudong125,项目名称:Windows-universal-samples,代码行数:9,代码来源:Scenario3_ServicingCompleteTask.xaml.cs
示例6: OnSyncWithDeviceCompleted
/// <summary>
/// Reopen the device after the background task is done syncing. Notify the UI of how many bytes we wrote to the device.
/// </summary>
/// <param name="sender"></param>
/// <param name="args"></param>
private async void OnSyncWithDeviceCompleted(BackgroundTaskRegistration sender, BackgroundTaskCompletedEventArgs args)
{
// Exception may be thrown if an error occurs during running the background task
args.CheckResult();
await rootPage.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
new DispatchedHandler(async () =>
{
// Reopen the device once the background task is completed
await EventHandlerForDevice.Current.OpenDeviceAsync(syncDeviceInformation, syncDeviceSelector);
syncDeviceInformation = null;
syncDeviceSelector = null;
var taskCompleteStatus = (String)ApplicationData.Current.LocalSettings.Values[LocalSettingKeys.SyncBackgroundTaskStatus];
if (taskCompleteStatus == SyncBackgroundTaskInformation.TaskCompleted)
{
UInt32 totalBytesWritten = (UInt32)ApplicationData.Current.LocalSettings.Values[LocalSettingKeys.SyncBackgroundTaskResult];
rootPage.NotifyUser("Sync: Wrote " + totalBytesWritten.ToString() + " bytes to the device", NotifyType.StatusMessage);
}
else if (taskCompleteStatus == SyncBackgroundTaskInformation.TaskCanceled)
{
rootPage.NotifyUser("Syncing was canceled", NotifyType.StatusMessage);
}
// Remove all local setting values
ApplicationData.Current.LocalSettings.Values.Clear();
isSyncing = false;
UpdateButtonStates();
}));
// Unregister the background task and let the remaining task finish until completion
if (backgroundSyncTaskRegistration != null)
{
backgroundSyncTaskRegistration.Unregister(false);
}
}
示例7: OnTaskCompleted
private async void OnTaskCompleted(BackgroundTaskRegistration task, BackgroundTaskCompletedEventArgs args)
{
await rootPage.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
rootPage.NotifyUser("Background task completed", NotifyType.StatusMessage);
});
}
示例8: OnCompleted
/// <summary>
/// This is the event handler for background task completion.
/// </summary>
/// <param name="task">The task that is reporting completion.</param>
/// <param name="args">The completion report arguments.</param>
private void OnCompleted(IBackgroundTaskRegistration task, BackgroundTaskCompletedEventArgs args)
{
string status = "Completed";
try
{
args.CheckResult();
}
catch (Exception e)
{
status = e.Message;
}
UpdateUIAsync(status);
}
开发者ID:C-C-D-I,项目名称:Windows-universal-samples,代码行数:18,代码来源:Scenario4_BackgroundProximitySensor.xaml.cs
示例9: OnCompleted
async private void OnCompleted(IBackgroundTaskRegistration sender, BackgroundTaskCompletedEventArgs e)
{
if (sender != null)
{
// Update the UI with progress reported by the background task
await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
try
{
// If the background task threw an exception, display the exception in
// the error text box.
e.CheckResult();
// Update the UI with the completion status of the background task
// The Run method of the background task sets this status.
var settings = ApplicationData.Current.LocalSettings;
if (settings.Values["Status"] != null)
{
rootPage.NotifyUser(settings.Values["Status"].ToString(), NotifyType.StatusMessage);
}
// Extract and display Latitude
if (settings.Values["Latitude"] != null)
{
ScenarioOutput_Latitude.Text = settings.Values["Latitude"].ToString();
}
else
{
ScenarioOutput_Latitude.Text = "No data";
}
// Extract and display Longitude
if (settings.Values["Longitude"] != null)
{
ScenarioOutput_Longitude.Text = settings.Values["Longitude"].ToString();
}
else
{
ScenarioOutput_Longitude.Text = "No data";
}
// Extract and display Accuracy
if (settings.Values["Accuracy"] != null)
{
ScenarioOutput_Accuracy.Text = settings.Values["Accuracy"].ToString();
}
else
{
ScenarioOutput_Accuracy.Text = "No data";
}
}
catch (Exception ex)
{
// The background task had an error
rootPage.NotifyUser(ex.ToString(), NotifyType.ErrorMessage);
}
});
}
}
示例10: OnCompleted
private void OnCompleted( IBackgroundTaskRegistration sender, BackgroundTaskCompletedEventArgs e )
{
if( sender != null )
{
// If the background task threw an exception, display the exception in
// the error text box.
e.CheckResult();
LocationChanged();
// if( settings.Values[ "Longitude" ] != null )
// if( settings.Values[ "Accuracy" ] != null )
}
}
示例11: OnCompleted
private async void OnCompleted(IBackgroundTaskRegistration sender, BackgroundTaskCompletedEventArgs e)
{
if (sender != null)
{
// Update the UI with progress reported by the background task
await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
try
{
// If the background task threw an exception, display the exception in the
// error text box.
e.CheckResult();
// Update the UI with the completion status of the background task The Run
// method of the background task sets this status.
var settings = ApplicationData.Current.LocalSettings;
if (settings.Values["Status"] != null)
{
Status.Text = settings.Values["Status"].ToString();
}
// Extract and display location data set by the background task if not null
MobilePosition_Latitude.Text = (settings.Values["Latitude"] == null) ? "No data" : settings.Values["Latitude"].ToString();
MobilePosition_Longitude.Text = (settings.Values["Longitude"] == null) ? "No data" : settings.Values["Longitude"].ToString();
MobilePosition_Accuracy.Text = (settings.Values["Accuracy"] == null) ? "No data" : settings.Values["Accuracy"].ToString();
}
catch (Exception ex)
{
// The background task had an error
Status.Text = ex.ToString();
}
});
}
}
示例12: Taskcompleted
private void Taskcompleted(BackgroundTaskRegistration sender, BackgroundTaskCompletedEventArgs args)
{
BackgroundMediaPlayer.Shutdown();
_deferral.Complete();
}
示例13: OnSyncWithDeviceCompleted
/// <summary>
/// Reopen the device after the background task is done syncing. Notify the UI of how many bytes we wrote to the device.
/// </summary>
/// <param name="sender"></param>
/// <param name="args"></param>
private async void OnSyncWithDeviceCompleted(BackgroundTaskRegistration sender, BackgroundTaskCompletedEventArgs args)
{
isSyncing = false;
// Exception may be thrown if an error occurs during running the background task
args.CheckResult();
await rootPage.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
new DispatchedHandler(async () =>
{
// Reopen the device once the background task is completed
// Don't attempt to reconnect if the device failed to connect
var isDeviceSuccessfullyConnected = await EventHandlerForDevice.Current.OpenDeviceAsync(syncDeviceInformation, syncDeviceSelector);
if (!isDeviceSuccessfullyConnected)
{
EventHandlerForDevice.Current.IsEnabledAutoReconnect = false;
}
syncDeviceInformation = null;
syncDeviceSelector = null;
// Since we are navigating away, don't touch the UI; we don't care what the output/result of the background task is
if (!navigatedAway)
{
var taskCompleteStatus = (String)ApplicationData.Current.LocalSettings.Values[LocalSettingKeys.SyncBackgroundTaskStatus];
if (taskCompleteStatus == SyncBackgroundTaskInformation.TaskCompleted)
{
UInt32 totalBytesWritten = (UInt32)ApplicationData.Current.LocalSettings.Values[LocalSettingKeys.SyncBackgroundTaskResult];
// Set the progress bar to be completely filled in case the progress was not updated (this can happen if the app is suspended)
SyncProgressBar.Value = 100;
rootPage.NotifyUser("Sync: Wrote " + totalBytesWritten.ToString() + " bytes to the device", NotifyType.StatusMessage);
}
else if (taskCompleteStatus == SyncBackgroundTaskInformation.TaskCanceled)
{
// Reset the progress bar in case the progress was not updated (this can happen if the app is suspended)
SyncProgressBar.Value = 0;
rootPage.NotifyUser("Syncing was canceled", NotifyType.StatusMessage);
}
UpdateButtonStates();
}
// Remove all local setting values
ApplicationData.Current.LocalSettings.Values.Clear();
}));
// Unregister the background task and let the remaining task finish until completion
if (backgroundSyncTaskRegistration != null)
{
backgroundSyncTaskRegistration.Unregister(false);
}
}
示例14: Mytask_Completed
private async void Mytask_Completed(BackgroundTaskRegistration sender, BackgroundTaskCompletedEventArgs args)
{
// Background task has completed - refresh our data
await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(
CoreDispatcherPriority.Normal,
async () => await LoadRuntimeDataAsync()
);
}
示例15: RegistrationCompleted
private void RegistrationCompleted(BackgroundTaskRegistration sender, BackgroundTaskCompletedEventArgs args)
{
ApplicationDataContainer container = ApplicationData.Current.LocalSettings;
try
{
var content = container.Values["RawMessage"].ToString();
if (content != null)
{
ToastMessage message = JsonConvert.DeserializeObject<ToastMessage>(content);
ToastHelper.DisplayTextToast(ToastTemplateType.ToastImageAndText01, message.FromId, message.Content, message.FromPicture);
}
}
catch (Exception ex)
{
ex.ToString();
}
}