Exemple #1
0
        public OkResult <object> Invoke(IBackgroundTaskScheduler taskScheduler)
        {
            taskScheduler.Enqueue(new ConsoleWritingBackgroundTask {
                Parameter = Parameter
            });

            return(new OkResult <object>(new
            {
                Scheduled = true,
            }));
        }
        /// <summary>
        /// Executes a number of task in a sequential fashion, one after the other.
        /// </summary>
        /// <param name="backgroundTaskScheduler">The scheduler on which to enqueue tasks.</param>
        /// <param name="tasks">The tasks that should be scheduled.</param>
        /// <param name="options">Options used to determine in what state the task should be considered for execution.</param>
        /// <returns>A <see cref="Task"/> representing the asynchronous operation, returning the <strong>final</strong> scheduled background task.</returns>
        public static IScheduledBackgroundTask EnqueueSequentially(
            this IBackgroundTaskScheduler backgroundTaskScheduler,
            IEnumerable <IBackgroundTask> tasks,
            BackgroundTaskContinuationOptions options = BackgroundTaskContinuationOptions.OnlyOnSucceededState)
        {
            IScheduledBackgroundTask scheduledTask = null;

            foreach (var taskToRun in tasks)
            {
                scheduledTask = scheduledTask == null?
                                backgroundTaskScheduler.Enqueue(taskToRun) :
                                    scheduledTask.ContinueWith(taskToRun, options);
            }

            return(scheduledTask);
        }
Exemple #3
0
            public object Invoke(IBackgroundTaskScheduler taskScheduler)
            {
                taskScheduler.Enqueue(new TestBackgroundTask());

                return(ToReturn);
            }