Scheduler
The Scheduler is a way of declaring tasks to execute on a given schedule and time zone. It provides an easy to use SDK for scheduling, automatic de-scheduling and re-scheduling for event tasks.
Demo Code
The demo code uses the Memory Scheduler
as it does not require a remote source. Typically speaking you would tie the event task descriptions back to a database record (like the MSSQL Scheduler Source).
Line 5 - Declare a new event source. This demo uses the memory scheduler.
Line 9-10 - Add the two scheduled items, A, and B, to schedule and execute
Line 13 - Add a scheduler using the source we defined, and declare the callback.
You're given a CancellationToken for respecting graceful shutdown event.
An ILogger for logging to the system and defined sink sources.
And the GenericScheduledItem<ushort> Which is the interfaced item that allows you to access it's definition values.
Line 14 - You can execute or perform any tasks you need. Like generating a report with parameters.
You can see the call to
GetRunType()
. There's alsoGetRunArgs()
,GetLastRunDate()
,GetName()
, etc.
SDK
Memory Source
The Memory source stores all records, run times, and event descriptions on the path specified. It's a great way to test, debug, or play with the scheduler without having to stand up a database. Typically speaking for production scenarios, you would likely use a remote source, like a database or file to maintain the scheduled items.
MSSQL Source
MSSQL Source is the example remote source included with the Scheduler. This source pulls records from a table in MSSQL which allows for 1 database record to create and maintain 1 scheduled task.
Using the MSSQL source is very easy, it only required a registered connection string credential.
The code can actually be found linked below.
Generic Scheduled Item <ushort>
This The included scheduled item interfaced class. It's suitable for most scenarios, but as the whole callback process is interfaced, you're able to implement your own class to use if needed.
Below are the interfaced methods for a scheduled item. These methods provide an easy way to retrieve the relevant properties on a scheduled task regardless of where that event description came from (in a database, a file, remotely, etc).
Code for Sources
Memory:
This memory source shows the most simplified way possible of implementing the interface and can be used to learn how it works.
MSSQL:
If you're writing a custom connector to another database engine, this is a great template and guide to do so:
Last updated