IJobExclusiveExecution Property |
Namespace: AGI.Parallel.Infrastructure
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; } } } }
STK Parallel Computing Server 2.9 API for .NET