IJobSchedulerContextCreateChildJob Method (Boolean)

Creates a child job.
Namespace:  AGI.Parallel.Infrastructure
Assembly:  AGI.Parallel.Infrastructure (in AGI.Parallel.Infrastructure.dll) Version: 1.3.0.366 (1.3.0.366)
Syntax
IJob CreateChildJob(
        bool yieldAllResourcesToChildren
)

Parameters

yieldAllResourcesToChildren
Type: SystemBoolean
if set to true yields all resources to children once the job is submitted.

Return Value

Type: IJob
Job which can be submitted back to same job scheduler that the current task was submitted to.
Examples
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";
            }
        }
    }
}
See Also

STK Scalability 1.3 API for .NET