Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

struct System.​Threading.​Tasks.​ValueTask

Assembly: System.Runtime

Implemented Interfaces

Provides an awaitable result of an asynchronous operation.

Properties

public static ValueTask
CompletedTask
Gets a task that has already completed successfully.
public bool
IsCanceled
Gets a value that indicates whether this object represents a canceled operation.
public bool
IsCompleted
Gets a value that indicates whether this object represents a completed operation.
public bool
IsCompletedSuccessfully
Gets a value that indicates whether this object represents a successfully completed operation.
public bool
IsFaulted
Gets a value that indicates whether this object represents a failed operation.

Methods

public Task
AsTask​()
Retrieves a <see cref="T:System.Threading.Tasks.Task" /> object that represents this <see cref="T:System.Threading.Tasks.ValueTask" /> .
Returns The <see cref="T:System.Threading.Tasks.Task" /> object that is wrapped in this <see cref="T:System.Threading.Tasks.ValueTask" /> if one exists, or a new <see cref="T:System.Threading.Tasks.Task" /> object that represents the result.
ConfigureAwait​(bool continueOnCapturedContext)
Configures an awaiter for this value.
Returns The configured awaiter.
continueOnCapturedContext <see langword="true" /> to attempt to marshal the continuation back to the captured context; otherwise, <see langword="false" /> .
public bool
Equals​(object obj)
Determines whether the specified object is equal to the current <see cref="T:System.Threading.Tasks.ValueTask" /> instance.
Returns <see langword="true" /> if the specified object is equal to the current object; otherwise, <see langword="false" /> .
obj The object to compare with the current object.
public bool
Equals​(ValueTask other)
Determines whether the specified <see cref="T:System.Threading.Tasks.ValueTask" /> object is equal to the current <see cref="T:System.Threading.Tasks.ValueTask" /> object.
Returns <see langword="true" /> if the specified object is equal to the current object; otherwise, <see langword="false" /> .
other The object to compare with the current object.
public static ValueTask
FromCanceled​(CancellationToken cancellationToken)
Creates a <see cref="T:System.Threading.Tasks.ValueTask" /> that has completed due to cancellation with the specified cancellation token.
Returns The canceled task.
cancellationToken The cancellation token with which to complete the task.
public static ValueTask<​TResult>
FromCanceled​(CancellationToken cancellationToken)
Creates a <see cref="T:System.Threading.Tasks.ValueTask`1" /> that has completed due to cancellation with the specified cancellation token.
Returns The canceled task.
cancellationToken The cancellation token with which to complete the task.
public static ValueTask
FromException​(Exception exception)
Creates a <see cref="T:System.Threading.Tasks.ValueTask" /> that has completed with the specified exception.
Returns The faulted task.
exception The exception with which to complete the task.
public static ValueTask<​TResult>
FromException​(Exception exception)
Creates a <see cref="T:System.Threading.Tasks.ValueTask`1" /> that has completed with the specified exception.
Returns The faulted task.
exception The exception with which to complete the task.
public static ValueTask<​TResult>
FromResult​(TResult result)
Creates a <see cref="T:System.Threading.Tasks.ValueTask`1" /> that's completed successfully with the specified result.
Returns The successfully completed task.
result The result to store into the completed task.
GetAwaiter​()
Creates an awaiter for this value.
Returns The awaiter.
public int
GetHashCode​()
Returns the hash code for this instance.
Returns The hash code for the current object.
public ValueTask
Preserve​()
Gets a <see cref="T:System.Threading.Tasks.ValueTask" /> that may be used at any point in the future.
Returns The preserved <see cref="T:System.Threading.Tasks.ValueTask" /> .
public string
ToString​()
Inherited from ValueType
Returns the fully qualified type name of this instance.
Returns The fully qualified type name.
protected void
Finalize​()
Inherited from object
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
public Type
GetType​()
Inherited from object
Gets the <see cref="T:System.Type" /> of the current instance.
Returns The exact runtime type of the current instance.
protected object
MemberwiseClone​()
Inherited from object
Creates a shallow copy of the current <see cref="T:System.Object" /> .
Returns A shallow copy of the current <see cref="T:System.Object" /> .