Class ValueTaskDelaySource
Represents a source of value tasks that complete after a specified amount of time has passed.
public sealed class ValueTaskDelaySource : IDisposable, IAsyncDisposable
- Inheritance
-
ValueTaskDelaySource
- Implements
- Inherited Members
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Remarks
All scheduled delays will be prematurely completed with Disposed result.
DisposeAsync()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.
public ValueTask DisposeAsync()
Returns
- ValueTask
A task that represents the asynchronous dispose operation.
Remarks
All scheduled delays will be prematurely completed with Disposed result.
GetResetEvent(bool)
Creates a new AsyncManualResetEvent instance backed by this delay source.
[Pure]
public AsyncManualResetEvent GetResetEvent(bool signaled = false)
Parameters
signaledboolSpecifies whether created event should start in signaled state. Equal to false by default.
Returns
- AsyncManualResetEvent
New AsyncManualResetEvent instance.
Schedule(Duration, CancellationToken)
Schedules a new delay value task.
public ValueTask<ValueTaskDelayResult> Schedule(Duration delay, CancellationToken cancellationToken = default)
Parameters
delayDurationAmount of time after which the returned value task completes.
cancellationTokenCancellationTokenOptional CancellationToken instance.
Returns
- ValueTask<ValueTaskDelayResult>
New ValueTask<TResult> instance which returns a ValueTaskDelayResult value.
Start(ITimestampProvider?)
Creates a new ValueTaskDelaySource instance.
[Pure]
public static ValueTaskDelaySource Start(ITimestampProvider? timestamps = null)
Parameters
timestampsITimestampProviderOptional Timestamp provider.
Returns
- ValueTaskDelaySource
New ValueTaskDelaySource instance.
Start(TaskFactory, ITimestampProvider?)
Creates a new ValueTaskDelaySource instance.
[Pure]
public static ValueTaskDelaySource Start(TaskFactory taskFactory, ITimestampProvider? timestamps = null)
Parameters
taskFactoryTaskFactoryTaskFactory instance that will be used to start an underlying task.
timestampsITimestampProviderOptional Timestamp provider.
Returns
- ValueTaskDelaySource
New ValueTaskDelaySource instance.