using System; using System.Runtime.CompilerServices; using System.Threading.Tasks; namespace Umbraco.Web.Scheduling { /// /// Wraps a within an object that gives access to its GetAwaiter method and Status /// property while ensuring that it cannot be modified in any way. /// public class ThreadingTaskImmutable { private readonly Task _task; /// /// Initializes a new instance of the class with a Task. /// /// The task. public ThreadingTaskImmutable(Task task) { if (task == null) throw new ArgumentNullException("task"); _task = task; } /// /// Gets an awaiter used to await the task. /// /// An awaiter instance. public TaskAwaiter GetAwaiter() { return _task.GetAwaiter(); } /// /// Gets the TaskStatus of the task. /// /// The current TaskStatus of the task. public TaskStatus Status { get { return _task.Status; } } } }