Class ManualResetCompletionSource
Represents base class for producer of value task.
Inheritance
Inherited Members
Namespace: DotNext.Threading.Tasks
Assembly: DotNext.Threading.dll
Syntax
public abstract class ManualResetCompletionSource
Fields
View SourceInitialCompletionToken
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 SourceCompletionData
Gets a value passed to the manual completion method.
Declaration
public object? CompletionData { get; }
Property Value
| Type | Description |
|---|---|
| object |
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.
Status
Gets the status of this source.
Declaration
public ManualResetCompletionSourceStatus Status { get; }
Property Value
| Type | Description |
|---|---|
| ManualResetCompletionSourceStatus |
Methods
View SourceAfterConsumed()
Invokes when this source is ready to reuse.
Declaration
protected virtual void AfterConsumed()
See Also
View SourceCleanUp()
Resets internal state of this source.
Declaration
protected virtual void CleanUp()
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.
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. |
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 |
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. |
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 |