Overview

Task constants provide pre-constructed constant task values. These are effective when using the async fast path.

API

public static class TaskConstants
{
  // A task that has been completed with the value "false".
  public static Task<bool> BooleanFalse { get; }

  // A task that has been completed with the value "true".
  public static Task<bool> BooleanTrue { get; }

  // A task that has been completed with the value "-1".
  public static Task<int> Int32NegativeOne { get; }

  // A task that has been completed with the value "0".
  public static Task<int> Int32Zero { get; }

  // A task that has been completed.
  public static Task Completed { get; }

  // A task that will never complete.
  public static Task Never { get; }

  // A task that has been canceled.
  public static Task Canceled { get; }
}

public static class TaskConstants<T>
{
  // A task that has been completed with the default value of "T".
  public static Task<T> Default { get; }

  // A task that will never complete.
  public static Task<T> Never { get; }

  // A task that has been canceled.
  public static Task<T> Canceled { get; }
}

Last edited Nov 17, 2012 at 2:35 PM by StephenCleary, version 3

Comments

No comments yet.