IMoBroScheduler
Scheduler that can be used to implement recurring tasks (e.g. polling sensor values or an external API).
info
Scheduled tasks will be put on halt whenever IMoBroPlugin.Pause
is invoked on the
plugin and automatically resumed once IMoBroPlugin.Resume
is invoked.
Functions
OneOff(Action, TimeSpan)
Schedules a one-off task that will only be called once
Parameters
Name | Type | Description |
---|---|---|
action | Action | The action to execute |
delay | TimeSpan | The delay before the execution |
Example
_scheduler.OneOff(UpdateDynamicMetrics, TimeSpan.FromSeconds(2));
Interval(Action, TimeSpan, TimeSpan)
Schedules a recurring task that will be called in the given interval
Parameters
Name | Type | Description |
---|---|---|
action | Action | The action to execute |
interval | TimeSpan | The recurring interval |
delay | TimeSpan | The delay before the execution |
Example
_scheduler.Interval(UpdateMetrics, TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(5));
Cron(Action, string, TimeZoneInfo, TimeSpan)
Schedules a recurring task based on a cron string
Cron string format
Parameters
Name | Type | Description |
---|---|---|
action | Action | The action to execute |
cron | string | The cron string |
timeZone | TimeZoneInfo | The timezone |
delay | TimeSpan | The delay before the execution |
Example
_scheduler.Cron(UpdateMetrics, "* * * * ? *", TimeZoneInfo.Utc, TimeSpan.FromSeconds(5));