Show / Hide Table of Contents

Class AsyncTimer

Represents asynchronous timer.

Inheritance
Object
AsyncTimer
Namespace: DotNext.Threading
Assembly: DotNext.Threading.dll
Syntax
public class AsyncTimer : Disposable
Remarks

This timer provides guarantees than two executions of timer callback cannot be overlapped, i.e. executed twice or more concurrently at the same time.

Constructors

| Improve this Doc View Source

AsyncTimer(Func<CancellationToken, Task<Boolean>>)

Initializes a new timer.

Declaration
public AsyncTimer(Func<CancellationToken, Task<bool>> callback)
Parameters
Type Name Description
Func<CancellationToken, Task<Boolean>> callback

The timer callback.

| Improve this Doc View Source

AsyncTimer(ValueFunc<CancellationToken, Task<Boolean>>)

Initializes a new timer.

Declaration
public AsyncTimer(ValueFunc<CancellationToken, Task<bool>> callback)
Parameters
Type Name Description
ValueFunc<CancellationToken, Task<Boolean>> callback

The timer callback.

Properties

| Improve this Doc View Source

IsRunning

Indicates that this timer is running.

Declaration
public bool IsRunning { get; }
Property Value
Type Description
Boolean

Methods

| Improve this Doc View Source

Dispose(Boolean)

Releases all resources associated with this timer.

Declaration
protected override void Dispose(bool disposing)
Parameters
Type Name Description
Boolean disposing

true if called from ; false if called from finalizer .

| Improve this Doc View Source

Start(TimeSpan, CancellationToken)

Starts the timer.

Declaration
public bool Start(TimeSpan period, CancellationToken token = null)
Parameters
Type Name Description
TimeSpan period

The time interval between invocations of the timer callback.

CancellationToken token

The token that can be used to stop execution of the timer.

Returns
Type Description
Boolean

true if timer was in stopped state; otherwise, false.

| Improve this Doc View Source

Start(TimeSpan, TimeSpan, CancellationToken)

Starts the timer.

Declaration
public bool Start(TimeSpan dueTime, TimeSpan period, CancellationToken token = null)
Parameters
Type Name Description
TimeSpan dueTime

The amount of time to delay before the invoking the timer callback.

TimeSpan period

The time interval between invocations of the timer callback.

CancellationToken token

The token that can be used to stop execution of the timer.

Returns
Type Description
Boolean

true if timer was in stopped state; otherwise, false.

| Improve this Doc View Source

StopAsync()

Stops timer execution.

Declaration
public Task<bool> StopAsync()
Returns
Type Description
Task<Boolean>

true if timer shutdown was initiated by the callback; otherwise, false.

Extension Methods

AsyncLockAcquisition.AcquireLockAsync<T>(T, TimeSpan)
AsyncLockAcquisition.AcquireLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, TimeSpan)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, TimeSpan)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireUpgradeableReadLockAsync<T>(T, TimeSpan)
AsyncLockAcquisition.AcquireUpgradeableReadLockAsync<T>(T, CancellationToken)
ExpressionBuilder.Const<T>(T)
ObjectExtensions.GetUserData<T>(T)
ObjectExtensions.IsOneOf<T>(T, IEnumerable<T>)
ObjectExtensions.IsOneOf<T>(T, T[])
ObjectExtensions.Decompose<T, R1, R2>(T, Func<T, R1>, Func<T, R2>, out R1, out R2)
ObjectExtensions.Decompose<T, R1, R2>(T, ValueFunc<T, R1>, ValueFunc<T, R2>, out R1, out R2)
ObjectExtensions.Decompose<T, R1, R2>(T, Func<T, R1>, Func<T, R2>)
ObjectExtensions.Decompose<T, R1, R2>(T, ValueFunc<T, R1>, ValueFunc<T, R2>)
LockAcquisition.AcquireReadLock<T>(T)
LockAcquisition.AcquireReadLock<T>(T, TimeSpan)
LockAcquisition.AcquireWriteLock<T>(T)
LockAcquisition.AcquireWriteLock<T>(T, TimeSpan)
LockAcquisition.AcquireUpgradeableReadLock<T>(T)
LockAcquisition.AcquireUpgradeableReadLock<T>(T, TimeSpan)
  • Improve this Doc
  • View Source
Back to top Generated by DocFX