Universal Windows Service Class Library

Monitor.Create Method 

Create a new instance of a specified implemented monitor class.

public static IMonitor Create(
   string typeString
);

Parameters

typeString
String containing the type of a specified monitor class.

Return Value

Object of the given monitor class or null.

Remarks

This function create a new instance of the given monitor class specified as type string.

Firstly the type of the monitor class will be searched in the executing assembly but if no matching type exists there all loaded assemblies will be searched if access is granted.

Exceptions

Exception TypeCondition
ArgumentNullExceptionThrown if no type was given.
TypeLoadExceptionMeans that the given type was not found in all loaded assemblies.

Example

// Try to create instance of a monitor and configure it
try
{
    IMonitor crashMonitor = Monitor.Create("uws.Monitors.CrashMonitor");
    crashMonitor.Configure(xmlElement);
    
    if (crashMonitor.Start() == true)
    {
        Console.WriteLine("Monitor was started");
    }
    else
    {
        Console.WriteLine("Could not start monitor");
    }
}
catch (Exception ex)
{
    Console.WriteLine("Could not create new monitor. " + ex.Message);
}

See Also

Monitor Class | uws.Monitors Namespace | IMonitor