Universal Windows Service Class Library

Trigger.Add Method (ITrigger, String)

Add the given trigger object to static trigger list.

public static void Add(
   ITrigger trigger,
   string name


Object of a implemented trigger class.
Name of the trigger which should be set or empty for no one.


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 TypeCondition
ArgumentNullExceptionThrown if no trigger or no name were given.
ExceptionThe given trigger is not configured or a trigger with given name already exists in list.


    // 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
    // Sign different functions on this trigger
    Trigger.SignOn(new TriggerEventHandler(myIntervalFunction), "myIntervalTrigger");
    Trigger.SignOn(new TriggerEventHandler(myDailyFunction));
    // Start the work of all static triggers
catch (Exception ex)

See Also

Trigger Class | uws.Triggers Namespace | Trigger.Add Overload List | ITrigger