// -------------------------------------------------------------------------------------------------------------------- // // Copyright (c) James South. // Licensed under the Apache License, Version 2.0. // // // Provides some syntactic sugar to run tasks. // // -------------------------------------------------------------------------------------------------------------------- namespace ImageProcessor.Web.Helpers { #region Using using System; using System.Threading.Tasks; #endregion /// /// Provides some syntactic sugar to run tasks. /// public sealed class TaskHelpers { /// /// Queues the specified work to run on the ThreadPool and returns a Task handle for that work. /// /// The work to execute asynchronously /// A Task that represents the work queued to execute in the ThreadPool. /// /// The parameter was null. /// public static Task Run(Action action) { return Task.Factory.StartNew(action); } /// /// Queues the specified work to run on the ThreadPool and returns a proxy for the /// Task(TResult) returned by . /// /// The type of the result returned by the proxy Task. /// The work to execute asynchronously /// A Task(TResult) that represents a proxy for the Task(TResult) returned by . /// /// The parameter was null. /// public static Task Run(Func function) { return Task.Factory.StartNew(function); } } }