Class PeriodicTask
Schedule an action to be periodically executed on the thread pool.
Namespace: Swan.Threading
Syntax
public sealed class PeriodicTask : IDisposable
Constructors
PeriodicTask(TimeSpan, Func<CancellationToken, Task>, CancellationToken)
Initializes a new instance of the PeriodicTask class.
Declaration
public PeriodicTask(TimeSpan interval, Func<CancellationToken, Task> action, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | interval | The interval between invocations of |
Func<CancellationToken, Task> | action | The callback to invoke periodically. |
CancellationToken | cancellationToken | A |
Fields
MinInterval
The minimum interval between action invocations.
The value of this field is equal to 100 milliseconds.
Declaration
public static readonly TimeSpan MinInterval
Field Value
Type | Description |
---|---|
TimeSpan |
Properties
Interval
Gets or sets the interval between periodic action invocations.
Changes to this property take effect after next action invocation.
Declaration
public TimeSpan Interval { get; set; }
Property Value
Type | Description |
---|---|
TimeSpan |
See Also
Methods
Dispose()
Declaration
public void Dispose()
Finalize()
Finalizes an instance of the PeriodicTask class.
Declaration
protected void Finalize()