Universal Windows Service Class Library

Monitor.Add Method 

Add the given monitor object to static monitor list.

public static void Add(
   IMonitor monitor,
   string name,
   ref EventArrayList appList


Object of a implemented monitor class.
Name of the monitor which must be set to reference monitor.
Referenced event list which contains already running applications.


The function add the given monitor object to static monitor list.

If no name was given an exception would be thrown. But if a name was given the function check if already a monitor with this name exists in list. It must be a unique one.

The static monitor list will be used for monitors which could be used from different triggers or something else.

To see the usage of the static monitor list see the example section below.


Exception TypeCondition
ArgumentNullExceptionThrown if no monitor, no name or no application list were given.
ExceptionThe given monitor is not configured or a monitor with given name already exists in list.


    // Create an crash monitor which fires every time an application exits
    IMonitor crashMonitor = new CrashMonitor();
    EventArrayList appList = new EventArrayList();
    // Add crash monitor to static monitor list using a specified name
    Monitor.Add(crashMonitor, "myCrashTrigger", ref appList);
    // Sign different functions on this monitor
    Monitor.SignOn(new MonitorEventHandler(myCrashFunction), "myCrashMonitor");
    // Start the work of all static monitors
catch (Exception ex)

See Also

Monitor Class | uws.Monitors Namespace | IMonitor