Show / Hide Table of Contents

Class ManualResetCompletionSource

Represents base class for producer of value task.

Inheritance
object
ManualResetCompletionSource
ValueTaskCompletionSource
ValueTaskCompletionSource<T>
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: DotNext.Threading.Tasks
Assembly: DotNext.Threading.dll
Syntax
public abstract class ManualResetCompletionSource

Fields

| Edit this page View Source

InitialCompletionToken

Represents initial value of the completion token when constructing a new instance of the completion source.

Declaration
protected const short InitialCompletionToken = -32768
Field Value
Type Description
short

Properties

| Edit this page View Source

CompletionData

Gets a value passed to the manual completion method.

Declaration
protected object? CompletionData { get; }
Property Value
Type Description
object
| Edit this page View Source

IsCompleted

Gets a value indicating that this source is in signaled (completed) state.

Declaration
public bool IsCompleted { get; }
Property Value
Type Description
bool
Remarks

This property returns true if Status is WaitForConsumption or Consumed.

| Edit this page View Source

Status

Gets the status of this source.

Declaration
public ManualResetCompletionSourceStatus Status { get; }
Property Value
Type Description
ManualResetCompletionSourceStatus

Methods

| Edit this page View Source

AfterConsumed()

Invokes when this source is ready to reuse.

Declaration
protected virtual void AfterConsumed()
See Also
CompletionData
| Edit this page View Source

CleanUp()

Resets internal state of this source.

Declaration
protected virtual void CleanUp()
| Edit this page View Source

Reset()

Resets the state of the source.

Declaration
public short Reset()
Returns
Type Description
short

The version of the uncompleted task.

Remarks

This methods acts as a barrier for completion. It means that calling of this method guarantees that the task cannot be completed by the previously linked timeout or cancellation token.

| Edit this page View Source

TryReset(out short)

Attempts to reset the state of this source.

Declaration
public bool TryReset(out short token)
Parameters
Type Name Description
short token

The version of the uncompleted task.

Returns
Type Description
bool

true if the state was reset successfully; otherwise, false.

See Also
Reset()
| Edit this page View Source

TrySetCanceled(object?, CancellationToken)

Attempts to complete the task unsuccessfully.

Declaration
public abstract bool TrySetCanceled(object? completionData, CancellationToken token)
Parameters
Type Name Description
object completionData

The data to be saved in CompletionData property that can be accessed from within AfterConsumed() method.

CancellationToken token

The canceled token.

Returns
Type Description
bool

true if the result is completed successfully; false if the task has been canceled or timed out.

| Edit this page View Source

TrySetCanceled(CancellationToken)

Attempts to complete the task unsuccessfully.

Declaration
public bool TrySetCanceled(CancellationToken token)
Parameters
Type Name Description
CancellationToken token

The canceled token.

Returns
Type Description
bool

true if the result is completed successfully; false if the task has been canceled or timed out.

| Edit this page View Source

TrySetException(Exception)

Attempts to complete the task unsuccessfully.

Declaration
public bool TrySetException(Exception e)
Parameters
Type Name Description
Exception e

The exception to be returned to the consumer.

Returns
Type Description
bool

true if the result is completed successfully; false if the task has been canceled or timed out.

| Edit this page View Source

TrySetException(object?, Exception)

Attempts to complete the task unsuccessfully.

Declaration
public abstract bool TrySetException(object? completionData, Exception e)
Parameters
Type Name Description
object completionData

The data to be saved in CompletionData property that can be accessed from within AfterConsumed() method.

Exception e

The exception to be returned to the consumer.

Returns
Type Description
bool

true if the result is completed successfully; false if the task has been canceled or timed out.

Extension Methods

BasicExtensions.As<T>(T)
BasicExtensions.GetUserData<T>(T)
BasicExtensions.IsBetween<T, TLowerBound, TUpperBound>(T, TLowerBound, TUpperBound)
BasicExtensions.IsOneOf<T>(T, ReadOnlySpan<T>)
ExpressionBuilder.Const<T>(T)
AsyncLockAcquisition.AcquireLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireLockAsync<T>(T, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, bool, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, bool, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, TimeSpan, CancellationToken)
LockAcquisition.AcquireReadLock<T>(T)
LockAcquisition.AcquireReadLock<T>(T, TimeSpan)
LockAcquisition.AcquireUpgradeableReadLock<T>(T)
LockAcquisition.AcquireUpgradeableReadLock<T>(T, TimeSpan)
LockAcquisition.AcquireWriteLock<T>(T)
LockAcquisition.AcquireWriteLock<T>(T, TimeSpan)
  • Edit this page
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾