Table of Contents

Terminate all jobs

This example uses the adTempus API to terminate all running jobs on the server.

// if the adTempus server is on a different computer, replace "." with the server name
using (var session = Scheduler.Connect(".", LoginAuthenticationType.Windows, "", ""))
{
    using (var context = session.NewDataContext())
    {
        var parms = new InstanceQueryParameters();
        //Add WellKnownOIDs.RootGroup to search the root group and all sub-groups
        parms.TargetObjects.Add(WellKnownOIDs.RootGroup);
        
        //look for all active instances
        parms.Statuses.AddRange(JobStatusHelpers.ActiveStatuses);

        var instances=context.GetJobHistory(parms);
        
        foreach(var instance in instances)
        {
            instance.Terminate(TerminationOptions.None);				
        }
    }
}