public static BackgroundTaskBuilder BuildTask(BackgroundTaskBuilderModel model, bool isNetworkRequested = false, bool cancelOnConditionLoss = true, BackgroundTaskRegistrationGroup group = null) { // Specify the background task var builder = new BackgroundTaskBuilder() { Name = model.Name }; if (model.Trigger != null) { builder.SetTrigger(model.Trigger); } builder.IsNetworkRequested = isNetworkRequested; builder.CancelOnConditionLoss = cancelOnConditionLoss; if (group != null) { builder.TaskGroup = group; } var conditions = model.GetConditions(); if (conditions.Count > 0) { foreach (var condition in conditions) { builder.AddCondition(condition); } } return(builder); }
internal static void RegisterBackgroundTasks() { IBackgroundCondition internetAvailableCondition = new SystemCondition(SystemConditionType.InternetAvailable), userPresentCondition = new SystemCondition(SystemConditionType.UserPresent), sessionConnectedCondition = new SystemCondition(SystemConditionType.SessionConnected), backgroundCostNotHighCondition = new SystemCondition(SystemConditionType.BackgroundWorkCostNotHigh); var conditions = new[] { internetAvailableCondition, // userPresentCondition, //sessionConnectedCondition }; var bgBuilderModel = new BackgroundTaskBuilderModel( "ToastNotificationAction", new ToastNotificationActionTrigger(), conditions ); var toastActionTask = BuildTask(bgBuilderModel, true, true, null); toastActionTask.Register(true, false, true); bgBuilderModel = new BackgroundTaskBuilderModel( "SyncNotifications", new TimeTrigger(15, false), conditions ); var syncTask = BuildTask(bgBuilderModel, true, true, null); syncTask.Register(true, false, true); }
private static BackgroundTaskBuilder BuildTask(BackgroundTaskBuilderModel model, string taskEntryPointName, bool isNetworkRequested = false, bool cancelOnConditionLoss = true, BackgroundTaskRegistrationGroup group = null) { // Specify the background task var builder = BuildTask(model, isNetworkRequested, cancelOnConditionLoss, group); builder.TaskEntryPoint = taskEntryPointName; return(builder); }
public static void RegisterAppTriggerBackgroundTasks() { IBackgroundCondition internetAvailableCondition = new SystemCondition(SystemConditionType.InternetAvailable), userPresentCondition = new SystemCondition(SystemConditionType.UserPresent), sessionConnectedCondition = new SystemCondition(SystemConditionType.SessionConnected), backgroundCostNotHighCondition = new SystemCondition(SystemConditionType.BackgroundWorkCostNotHigh); var conditions = new[] { internetAvailableCondition, //userPresentCondition, //sessionConnectedCondition }; var bgBuilderModel = new BackgroundTaskBuilderModel( "AppTrigger", conditions ); var builder = BuildTask(bgBuilderModel, true, true, null); builder.Register(GetAppTrigger(), all: false); }
public static BackgroundTaskBuilder BuildTask <T>(BackgroundTaskBuilderModel model, bool isNetworkRequested = false, bool cancelOnConditionLoss = true, BackgroundTaskRegistrationGroup group = null) where T : IBackgroundTask { return(BuildTask(model, typeof(T).FullName, isNetworkRequested, cancelOnConditionLoss, group)); }
public static BackgroundTaskBuilder BuildTask(BackgroundTaskBuilderModel model, Type entryPointType, bool isNetworkRequested = false, bool cancelOnConditionLoss = true, BackgroundTaskRegistrationGroup group = null) { return(BuildTask(model, entryPointType.FullName, isNetworkRequested, cancelOnConditionLoss, group)); }