Class TimerTask<TKey>
Represents a reactive task that can be registered in an IEventStream<TEvent> with WithInterval<TEvent> events.
public abstract class TimerTask<TKey> : ITimerTask<TKey>, IDisposable where TKey : notnull
Type Parameters
TKeyTask key type.
- Inheritance
-
TimerTask<TKey>
- Implements
-
ITimerTask<TKey>
- Inherited Members
Constructors
TimerTask(TKey, Timestamp?, int, int)
Creates a new TimerTask<TKey> instance.
protected TimerTask(TKey key, Timestamp? nextInvocationTimestamp = null, int maxEnqueuedInvocations = 0, int maxConcurrentInvocations = 1)
Parameters
keyTKeyUnderlying key.
nextInvocationTimestampTimestamp?Specifies the Timestamp of the next task invocation. Lack of value means that the task will be invoked on every event stream's event. Equal to null by default.
maxEnqueuedInvocationsintSpecifies the maximum number of invocations that can be enqueued due to maximum concurrency. Equal to 0 by default.
maxConcurrentInvocationsintSpecifies the maximum number of concurrently running invocations. Equal to 1 by default.
Properties
Key
Underlying key.
public TKey Key { get; }
Property Value
- TKey
MaxConcurrentInvocations
Specifies the maximum number of concurrently running invocations.
public int MaxConcurrentInvocations { get; }
Property Value
MaxEnqueuedInvocations
Specifies the maximum number of invocations that can be enqueued due to maximum concurrency.
public int MaxEnqueuedInvocations { get; }
Property Value
NextInvocationTimestamp
Specifies the Timestamp of the next task invocation. Lack of value means that the task will be invoked on every event stream's event.
public Timestamp? NextInvocationTimestamp { get; protected set; }
Property Value
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public virtual void Dispose()
InvokeAsync(TimerTaskCollection<TKey>, ReactiveTaskInvocationParams, CancellationToken)
Invokes the task.
public abstract Task InvokeAsync(TimerTaskCollection<TKey> source, ReactiveTaskInvocationParams parameters, CancellationToken cancellationToken)
Parameters
sourceTimerTaskCollection<TKey>Source timer task collection.
parametersReactiveTaskInvocationParamsInvocation parameters.
cancellationTokenCancellationTokenCancellationToken instance.
Returns
OnCompleted(TimerTaskCollection<TKey>, ReactiveTaskCompletionParams)
Callback for task invocation completion.
public virtual void OnCompleted(TimerTaskCollection<TKey> source, ReactiveTaskCompletionParams parameters)
Parameters
sourceTimerTaskCollection<TKey>Source timer task collection.
parametersReactiveTaskCompletionParamsCompletion parameters.
OnEnqueue(TimerTaskCollection<TKey>, ReactiveTaskInvocationParams, int)
Callback invoked before the task invocation gets enqueued due to maximum concurrency.
public virtual bool OnEnqueue(TimerTaskCollection<TKey> source, ReactiveTaskInvocationParams parameters, int positionInQueue)
Parameters
sourceTimerTaskCollection<TKey>Source timer task collection.
parametersReactiveTaskInvocationParamsInvocation parameters.
positionInQueueintInvocation's position in queue.
Returns
- bool
true to proceed with enqueueing, false to cancel the invocation.