Development · Native API migration preview · Coverage validation in progress Published release →

API Browser

Class

Task<T>

class Task<T>

Module: System.Concurrency.Tasks
Assembly: System.Runtime.dll
Source file: Tasks.rvn

Inheritance: Object → Task<T>
Implements: TaskAwaiter

A consumer handle for one eventual value or cancellation.

Type parameters

Name Description
T The value type carried by successful completion, including Result values for expected failures.

Remarks

Obtain a task from Promise&lt;T&gt;.Task, an async method, Task.CompletedTask or Task.FromResult(value). Consumers cannot complete it. Expected failures belong in the result type; there is no faulted Task state. This provisional API is confined to one guest invocation. Callback methods using Func<System.Void> are described in the callback guide.

Properties

4 items
IsCancelled: bool Gets whether the producer cancelled the task.
IsCompleted: bool Gets whether the task has reached either terminal state.
Outcome: Optional<TaskOutcome<T>> Gets None while pending, or Some containing Completed(value) or Cancelled.
State: TaskState Gets Pending, Completed or Cancelled.

Methods

10 items
Equals(other: object?) -> bool Tests reference identity by default; an ordinary class may override equality. Inherited from Object.Equals
GetAwaiter() -> Task<T> Returns this task for the await protocol.
GetHashCode() -> int Returns a stable identity hash by default; an ordinary class may override it consistently with equality. Inherited from Object.GetHashCode
GetResult() -> T Reads the completed value without waiting.
GetType() -> TypeInfo Returns metadata for the concrete runtime type of this instance. Inherited from Object.GetType
Extension member: Map<U>(transform: (T) -> U) -> Task<U> No summary available. Extension from TaskOperators.Map
Extension member: MapResult<U>(transform: (T) -> U) -> Task<Result<U, E>> No summary available. Extension from TaskResultOperators.MapResultApplies to Task<Result<T, E>>.
OnCompleted(callback: () -> ()) -> () No summary available. Implements TaskAwaiter.OnCompleted
Extension member: Then<U>(continuation: (T) -> Task<U>) -> Task<U> No summary available. Extension from TaskOperators.Then
ToString() -> string Returns the concrete runtime type name for supported references, or display text from a class or boxed-struct override. Inherited from Object.ToString