JobTaskCompleted Event |
Namespace: AGI.Parallel.Client
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(); // Method 1. Use the TaskCompleted property on the job. Job job = scheduler.CreateJob(); job.AddTask(new OurTask()); job.TaskCompleted += new EventHandler<TaskCompletedEventArgs>(OnTaskCompleted); job.Submit(); job.WaitUntilDone(); } using (IJobScheduler scheduler = new ClusterJobScheduler("localhost")) { scheduler.Connect(); // Method 2. Use the Completed property on the task. Job job = scheduler.CreateJob(); Task task = new OurTask(); task.Completed += new EventHandler<EventArgs>(OnCompleted); job.AddTask(task); job.Submit(); job.WaitUntilDone(); } } private static void OnTaskCompleted(object sender, TaskCompletedEventArgs e) { // You could process the results here. Console.WriteLine("Task finished..."); Console.WriteLine(e.Task.TaskStatus); Console.WriteLine(e.Task.Result); } private static void OnCompleted(object sender, EventArgs e) { // You could process the results here. Console.WriteLine("Task finished..."); Task task = (Task)sender; Console.WriteLine(task.TaskStatus); Console.WriteLine(task.Result); } } [Serializable] class OurTask : Task { public override void Execute() { } } }
STK Parallel Computing Server 2.9 API for .NET