Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
DelayedActions.cs
1using System;
2using System.Threading.Tasks;
4
5namespace LegalLab.Models
6{
10 public static class DelayedActions
11 {
12 private static readonly Scheduler scheduler = new Scheduler();
13
19 public static void Add(IDelayedAction Action, DateTime When)
20 {
21 DateTime TP = Action.ScheduledFor;
22 if (TP != DateTime.MinValue)
23 {
24 Action.ScheduledFor = DateTime.MinValue;
25 scheduler.Remove(TP);
26 }
27
28 Action.ScheduledFor = scheduler.Add(When, ExecuteAction, Action);
29 }
30
35 public static void Remove(IDelayedAction Action)
36 {
37 if (Action.ScheduledFor != DateTime.MinValue)
38 {
39 Action.ScheduledFor = DateTime.MinValue;
40 scheduler.Remove(Action.ScheduledFor);
41 }
42 }
43
44 private static async Task ExecuteAction(object P)
45 {
47 await Action.Action();
48 }
49 }
50}
Class that can be used to schedule events in time. It uses a timer to execute tasks at the appointed ...
Definition: Scheduler.cs:26