Show / Hide Table of Contents

Class ManualResetCompletionSource

Represents base class for producer of value task.

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

Fields

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

View Source

CompletionData

Gets a value passed to the manual completion method.

Declaration
public object? CompletionData { get; }
Property Value
Type Description
object
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.

View Source

Status

Gets the status of this source.

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

Methods

View Source

AfterConsumed()

Invokes when this source is ready to reuse.

Declaration
protected virtual void AfterConsumed()
See Also
CompletionData
View Source

CleanUp()

Resets internal state of this source.

Declaration
protected virtual void CleanUp()
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 method 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.

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.

View Source

TrySetCanceled<TOptions>(TOptions, CancellationToken)

Attempts to complete the task unsuccessfully.

Declaration
public bool TrySetCanceled<TOptions>(TOptions options, CancellationToken token) where TOptions : ManualResetCompletionSource.ICompletionOptions, allows ref struct
Parameters
Type Name Description
TOptions options

The completion options.

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.

Type Parameters
Name Description
TOptions
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.

View Source

TrySetException<TOptions>(TOptions, Exception)

Attempts to complete the task unsuccessfully.

Declaration
public abstract bool TrySetException<TOptions>(TOptions options, Exception e) where TOptions : ManualResetCompletionSource.ICompletionOptions, allows ref struct
Parameters
Type Name Description
TOptions options

The completion options.

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.

Type Parameters
Name Description
TOptions

Extension Methods

BasicExtensions.As<T>(T)
BasicExtensions.IsBetween<T, TLowerBound, TUpperBound>(T, TLowerBound, TUpperBound)
BasicExtensions.IsOneOf<T>(T, params ReadOnlySpan<T>)
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾