Cancels all tasks in this job. Will not listen for cancellation events.
Namespace: AGI.Parallel.Client
Assembly: AGI.Parallel.Client (in AGI.Parallel.Client.dll) Version: 1.2.0.275 (1.2.0.275)

Syntax

C#
public void Cancel()
Visual Basic
Public Sub Cancel

Implements

IJob..::..Cancel()()()()

Examples

  Copy imageCopy
using System;
using System.Threading;
using AGI.Parallel.Client;
using AGI.Parallel.Infrastructure;

namespace CodeSamples
{
    class Program
    {
        static void Main(string[] args)
        {
            using (IJobScheduler scheduler = new ClusterJobScheduler("localhost"))
            {
                scheduler.Connect();
                Job job = scheduler.CreateJob();

                for (int i = 0; i < 100; ++i)
                {
                    job.AddTask(new WaitTask());
                }

                job.Submit();

                // Wait 10 seconds so the tasks queue up.
                Thread.Sleep(10000);

                // Cancel all the tasks in this job.
                job.Cancel();                

                job.WaitUntilDone();
            }
        }

        [Serializable]
        class WaitTask : Task
        {
            public override void Execute()
            {
                for (int i = 0; i < 100; ++i)
                {
                    Thread.Sleep(100);
                }
            }
        }
    }
}

See Also