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
| Edit this page 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
| Edit this page View SourceCompletionData
Gets a value passed to the manual completion method.
Declaration
protected 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
| Edit this page View SourceAfterConsumed()
Invokes when this source is ready to reuse.
Declaration
protected virtual void AfterConsumed()
See Also
| Edit this page 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 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.
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 |
See Also
| Edit this page View SourceTrySetCanceled(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. |
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. |
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(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. |