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
TKey
Task 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
key
TKeyUnderlying key.
nextInvocationTimestamp
Timestamp?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.
maxEnqueuedInvocations
intSpecifies the maximum number of invocations that can be enqueued due to maximum concurrency. Equal to 0 by default.
maxConcurrentInvocations
intSpecifies 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
source
TimerTaskCollection<TKey>Source timer task collection.
parameters
ReactiveTaskInvocationParamsInvocation parameters.
cancellationToken
CancellationTokenCancellationToken instance.
Returns
OnCompleted(TimerTaskCollection<TKey>, ReactiveTaskCompletionParams)
Callback for task invocation completion.
public virtual void OnCompleted(TimerTaskCollection<TKey> source, ReactiveTaskCompletionParams parameters)
Parameters
source
TimerTaskCollection<TKey>Source timer task collection.
parameters
ReactiveTaskCompletionParamsCompletion 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
source
TimerTaskCollection<TKey>Source timer task collection.
parameters
ReactiveTaskInvocationParamsInvocation parameters.
positionInQueue
intInvocation's position in queue.
Returns
- bool
true to proceed with enqueueing, false to cancel the invocation.