Table of Contents

Class TimerTask<TKey>

Namespace
LfrlAnvil.Reactive.Chrono
Assembly
LfrlAnvil.Reactive.Chrono.dll

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
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 TKey

Underlying 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 int

Specifies the maximum number of invocations that can be enqueued due to maximum concurrency. Equal to 0 by default.

maxConcurrentInvocations int

Specifies 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

int

MaxEnqueuedInvocations

Specifies the maximum number of invocations that can be enqueued due to maximum concurrency.

public int MaxEnqueuedInvocations { get; }

Property Value

int

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

Timestamp?

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 ReactiveTaskInvocationParams

Invocation parameters.

cancellationToken CancellationToken

CancellationToken instance.

Returns

Task

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 ReactiveTaskCompletionParams

Completion 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 ReactiveTaskInvocationParams

Invocation parameters.

positionInQueue int

Invocation's position in queue.

Returns

bool

true to proceed with enqueueing, false to cancel the invocation.