Add the given trigger object to static trigger list.
The function add the given trigger object to static trigger list.
If no name was given the trigger will simply be entered to static trigger list. But if a name was given the function check if already a trigger with this name exists in list.
The static trigger list will be used for global trigger which could be used from different objects.
To see the usage of the static trigger list see the example section below.
Exception Type | Condition |
---|---|
ArgumentNullException | Thrown if no trigger or no name were given. |
Exception | The given trigger is not configured or a trigger with given name already exists in list. |
try { // Create an interval trigger which fires every 1 minute and 10 seconds ITrigger intervalTrigger = new IntervalTrigger(0, 0, 1, 10); // Create a daily trigger which fires every day at 10:05:00 ITrigger dailyTrigger = new DailyTrigger(10, 5, 0); // Add interval trigger to static trigger list using a specified name Trigger.Add(intervalTrigger, "myIntervalTrigger"); // Add daily trigger to static trigger list without a name Trigger.Add(dailyTrigger); // Sign different functions on this trigger Trigger.SignOn(new TriggerEventHandler(myIntervalFunction), "myIntervalTrigger"); Trigger.SignOn(new TriggerEventHandler(myDailyFunction)); // Start the work of all static triggers Trigger.Begin(); } catch (Exception ex) { Console.WriteLine(ex.Message); }
Trigger Class | uws.Triggers Namespace | Trigger.Add Overload List | ITrigger