Gets or sets a value indicating whether the tasks on this job should have exclusive access to the resource it is running on.
Namespace: AGI.Parallel.Infrastructure
Assembly: AGI.Parallel.Infrastructure (in AGI.Parallel.Infrastructure.dll) Version: 1.2.0.275 (1.2.0.275)

Syntax

C#
bool ExclusiveExecution { get; set; }
Visual Basic
Property ExclusiveExecution As Boolean
        Get
        Set

Field Value

true if this the tasks on this job has exclusive access; otherwise, false.

Remarks

Tasks can either consume a single core of all the cores of an agent. An exclusive job means that all the task of a job will consume all the cores of an agent. The ExclusiveExecution flag prevents any other task to be executed concurrently.

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();

                // Set ExclusiveExecution to true
                job.ExclusiveExecution = true;

                for (int i = 0; i < 3; ++i)
                {
                    Task task = new OnlyTaskThatIsRunning();
                    job.AddTask(task);
                }

                job.Submit();
                job.WaitUntilDone();

                for (int i = 0; i < 3; ++i)
                {
                    DateTime start = job.Tasks[i].GetProperty<DateTime>(TaskProperties.HostStartTime);
                    DateTime end = job.Tasks[i].GetProperty<DateTime>(TaskProperties.HostEndTime);
                    Console.WriteLine("Task #{0} ran on {1} from {2} to {3}", i + 1, job.Tasks[i].Result, start, end);
                }
            }

            /*
             * The output of the application should resemble:
             * Task #1 ran on MyComputerName from 2/28/2013 5:34:24 PM to 2/28/2013 5:34:29 PM
             * Task #2 ran on MyComputerName from 2/28/2013 5:34:29 PM to 2/28/2013 5:34:34 PM
             * Task #3 ran on MyComputerName from 2/28/2013 5:34:34 PM to 2/28/2013 5:34:39 PM
             */
        }

        [Serializable]
        public class OnlyTaskThatIsRunning : Task
        {
            public override void Execute()
            {
                Thread.Sleep(5000);
                this.Result = Environment.MachineName;
            }
        }
    }
}

See Also