IJobSchedulerContextCreateChildJob Method |
Namespace: AGI.Parallel.Infrastructure
using System; 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(); job.AddTask(new ParentTask()); job.Submit(); job.WaitUntilDone(); Console.WriteLine(job.Tasks[0].Result); } /* * The output of the application should resemble: * From Parent -> From Child */ } [Serializable] public class ParentTask : Task { public override void Execute() { // Get the instance of the job scheduler context IJobSchedulerContext schedulerContext = this.GetProperty<IJobSchedulerContext>(TaskProperties.JobSchedulerContext); // Create a child job by calling CreateChildJob. IJob job = schedulerContext.CreateChildJob(); Task task = new ChildTask(); job.AddTask(task); job.Submit(); job.WaitUntilDone(); this.Result = "From Parent -> " + task.Result; } } [Serializable] public class ChildTask : Task { public override void Execute() { this.Result = "From Child"; } } } }
STK Parallel Computing Server 2.9 API for .NET