Scheduler
Demo Code
PerigeeApplication.ApplicationNoInit("Demo Scheduler", (c) =>
{
//Declare a new memory source, remember to use a single instance of memory/file based sources or locking can occur
using var MemSource = new MemoryScheduledSource("memSource.json", c.CTS.Token);
//Add scheduled items.
//If this was something like a DatabaseScheduledSource, we obviously would control these records from the database, not here.
MemSource.AddIfNotExists(GenericScheduledItem<ushort>.MemoryItem(0, "A scheduler, 15sec", "A", "a;b;c", "*/15 * * * * *", TimeZoneInfo.Local));
MemSource.AddIfNotExists(GenericScheduledItem<ushort>.MemoryItem(1, "B scheduler, 45sec", "B", "b;c;d", "45 * * * * *", TimeZoneInfo.Local));
//Add a scheduler with the MemorySource, a single callback is given for anything required to run (multi-threaded)
c.AddScheduler("Main", MemSource, (ct, l, item) => {
if (item.GetRunType() == "A")
{
l.LogInformation("Running A with {args}", item.GetRunArgs());
}
else if (item.GetRunType() == "B")
{
l.LogInformation("Running B with {args}", item.GetRunArgs());
}
});
});SDK
Memory Source
MSSQL Source
Generic Scheduled Item <ushort>
Code for Sources
Memory:
MSSQL:
Last updated

