Class ManualResetValueTaskSource<TResult>
Represents an implementation of an object that can be wrapped by a ValueTask<TResult>.
public sealed class ManualResetValueTaskSource<TResult> : IValueTaskSource<TResult>
Type Parameters
TResultThe type of the result produced by the ManualResetValueTaskSource<TResult>.
- Inheritance
-
ManualResetValueTaskSource<TResult>
- Implements
-
IValueTaskSource<TResult>
- Inherited Members
- Extension Methods
Constructors
ManualResetValueTaskSource(bool)
Creates a new ManualResetValueTaskSource<TResult> instance.
public ManualResetValueTaskSource(bool runContinuationsAsynchronously = true)
Parameters
runContinuationsAsynchronouslyboolSpecifies whether to force continuations to run asynchronously. Equal to true by default.
Properties
RunContinuationsAsynchronously
Specifies whether continuations are forced to run asynchronously.
public bool RunContinuationsAsynchronously { get; }
Property Value
Status
Specifies the status of this value task source's current operation.
public ValueTaskSourceStatus Status { get; }
Property Value
Methods
GetTask()
Creates a ValueTask<TResult> instance from this value task source.
public ValueTask<TResult> GetTask()
Returns
- ValueTask<TResult>
New ValueTask<TResult> instance.
Remarks
The returned value task will complete once this value task source is manually told to complete.
Reset()
Resets this value task source in order to prepare it for the next operation.
public void Reset()
SetCancelled(CancellationToken)
Completes this value task source's current operation with a cancellation.
public void SetCancelled(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenCancellation token associated with the operation.
Exceptions
- InvalidOperationException
When current operation has already been completed.
SetException(Exception)
Completes this value task source's current operation with an error.
public void SetException(Exception error)
Parameters
errorExceptionException of the operation.
Exceptions
- InvalidOperationException
When current operation has already been completed.
SetResult(TResult)
Completes this value task source's current operation with a successful result.
public void SetResult(TResult result)
Parameters
resultTResultResult of the operation.
Exceptions
- InvalidOperationException
When current operation has already been completed.
ToString()
Returns a string that represents the current object.
[Pure]
public override string ToString()
Returns
- string
A string that represents the current object.
TrySetCancelled(CancellationToken)
Attempts to complete this value task source's current operation with a cancellation.
public bool TrySetCancelled(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenCancellation token associated with the operation.
Returns
- bool
true when cancellation has been set successfully, otherwise false.
TrySetException(Exception)
Attempts to complete this value task source's current operation with an error.
public bool TrySetException(Exception error)
Parameters
errorExceptionException of the operation.
Returns
- bool
true when exception has been set successfully, otherwise false.
TrySetResult(TResult)
Attempts to complete this value task source's current operation with a successful result.
public bool TrySetResult(TResult result)
Parameters
resultTResultResult of the operation.
Returns
- bool
true when result has been set successfully, otherwise false.