Interface ITimerScheduler
Support for scheduled "Self" messages in an actor.
Timers are bound to the lifecycle of the actor that owns it, and thus are cancelled automatically when it is restarted or stopped.
ITimerScheduler is not thread-safe, i.e.it must only be used within the actor that owns it.
Namespace: Akka.Actor
Assembly: Akka.dll
Syntax
public interface ITimerScheduler
Properties
| Improve this Doc View SourceActiveTimers
Retrieves all current active timer keys
Declaration
IReadOnlyCollection<object> ActiveTimers { get; }
Property Value
Type | Description |
---|---|
IReadOnlyCollection<Object> |
Methods
| Improve this Doc View SourceCancel(Object)
Cancel a timer with a given key
.
If canceling a timer that was already canceled, or key never was used to start a timer
this operation will do nothing.
It is guaranteed that a message from a canceled timer, including its previous incarnation for the same key, will not be received by the actor, even though the message might already be enqueued in the mailbox when cancel is called.
Declaration
void Cancel(object key)
Parameters
Type | Name | Description |
---|---|---|
Object | key | Name of timer |
CancelAll()
Cancel all timers.
Declaration
void CancelAll()
IsTimerActive(Object)
Check if a timer with a given key
is active.
Declaration
bool IsTimerActive(object key)
Parameters
Type | Name | Description |
---|---|---|
Object | key |
Returns
Type | Description |
---|---|
Boolean | Name of timer |
StartPeriodicTimer(Object, Object, TimeSpan)
Start a periodic timer that will send msg
to the "Self" actor at
a fixed interval
.
Each timer has a key and if a new timer with same key is started the previous is cancelled and it's guaranteed that a message from the previous timer is not received, even though it might already be enqueued in the mailbox when the new timer is started.
Declaration
void StartPeriodicTimer(object key, object msg, TimeSpan interval)
Parameters
Type | Name | Description |
---|---|---|
Object | key | Name of timer |
Object | msg | Message to schedule |
TimeSpan | interval | Interval |
StartPeriodicTimer(Object, Object, TimeSpan, IActorRef)
Start a periodic timer that will send msg
to the "Self" actor at
a fixed interval
.
Each timer has a key and if a new timer with same key is started the previous is cancelled and it's guaranteed that a message from the previous timer is not received, even though it might already be enqueued in the mailbox when the new timer is started.
Declaration
void StartPeriodicTimer(object key, object msg, TimeSpan interval, IActorRef sender)
Parameters
Type | Name | Description |
---|---|---|
Object | key | Name of timer |
Object | msg | Message to schedule |
TimeSpan | interval | Interval |
IActorRef | sender | The sender override for the timer message |
StartPeriodicTimer(Object, Object, TimeSpan, TimeSpan)
Start a periodic timer that will send msg
to the "Self" actor at
a fixed interval
.
Each timer has a key and if a new timer with same key is started the previous is cancelled and it's guaranteed that a message from the previous timer is not received, even though it might already be enqueued in the mailbox when the new timer is started.
Declaration
void StartPeriodicTimer(object key, object msg, TimeSpan initialDelay, TimeSpan interval)
Parameters
Type | Name | Description |
---|---|---|
Object | key | Name of timer |
Object | msg | Message to schedule |
TimeSpan | initialDelay | Initial delay |
TimeSpan | interval | Interval |
StartPeriodicTimer(Object, Object, TimeSpan, TimeSpan, IActorRef)
Start a periodic timer that will send msg
to the "Self" actor at
a fixed interval
.
Each timer has a key and if a new timer with same key is started the previous is cancelled and it's guaranteed that a message from the previous timer is not received, even though it might already be enqueued in the mailbox when the new timer is started.
Declaration
void StartPeriodicTimer(object key, object msg, TimeSpan initialDelay, TimeSpan interval, IActorRef sender)
Parameters
Type | Name | Description |
---|---|---|
Object | key | Name of timer |
Object | msg | Message to schedule |
TimeSpan | initialDelay | Initial delay |
TimeSpan | interval | Interval |
IActorRef | sender | The sender override for the timer message |
StartSingleTimer(Object, Object, TimeSpan)
Start a timer that will send msg
once to the "Self" actor after
the given timeout
.
Each timer has a key and if a new timer with same key is started the previous is cancelled and it's guaranteed that a message from the previous timer is not received, even though it might already be enqueued in the mailbox when the new timer is started.
Declaration
void StartSingleTimer(object key, object msg, TimeSpan timeout)
Parameters
Type | Name | Description |
---|---|---|
Object | key | Name of timer |
Object | msg | Message to schedule |
TimeSpan | timeout | Interval |
StartSingleTimer(Object, Object, TimeSpan, IActorRef)
Start a timer that will send msg
once to the "Self" actor after
the given timeout
.
Each timer has a key and if a new timer with same key is started the previous is cancelled and it's guaranteed that a message from the previous timer is not received, even though it might already be enqueued in the mailbox when the new timer is started.
Declaration
void StartSingleTimer(object key, object msg, TimeSpan timeout, IActorRef sender)
Parameters
Type | Name | Description |
---|---|---|
Object | key | Name of timer |
Object | msg | Message to schedule |
TimeSpan | timeout | Interval |
IActorRef | sender | The sender override for the timer message |