Sets progress of task. This value will be returned with AGI.Parallel.Client.Job.TaskProgressUpdated event.
Namespace: AGI.Parallel.Infrastructure
Assembly: AGI.Parallel.Infrastructure (in AGI.Parallel.Infrastructure.dll) Version: 1.2.0.275 (1.2.0.275)

Syntax

C#
public void SetProgress(
        int progress,
        Object additionalInformation
)
Visual Basic
Public Sub SetProgress ( _
        progress As Integer, _
        additionalInformation As Object _
)

Parameters

progress
Type: System..::..Int32
The progress of task.
additionalInformation
Type: System..::..Object
Additional argument that will be marshalled to AGI.Parallel.Client.Job.TaskProgressUpdated event.

Remarks

The additionalInformation value must be a primitive type. For example, string, integer, double, or byte[].

Examples

  Copy imageCopy
using System;
using System.Collections.Generic;
using System.Diagnostics;
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 ProgressTask());

                // Subscribe to TaskProgressUpdated
                job.TaskProgressUpdated += new EventHandler<TaskProgressEventArgs>(Job_TaskProgressUpdated);

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

            /*
             * The output of the application should resemble:
             * 0 1
             * 20 B
             * 40 4
             * 60 D
             * 80 E
             */
        }

        private static void Job_TaskProgressUpdated(object sender, TaskProgressEventArgs e)
        {
            Console.WriteLine("{0} {1}", e.Description.Progress, e.Description.AdditionalInformation);
        }

        [Serializable]
        public class ProgressTask : Task
        {
            public override void Execute()
            {
                this.SetProgress(0, 1);
                System.Threading.Thread.Sleep(1000);
                this.SetProgress(20, "B");
                System.Threading.Thread.Sleep(1000);
                this.SetProgress(40, 4);
                System.Threading.Thread.Sleep(1000);
                this.SetProgress(60, "D");
                System.Threading.Thread.Sleep(1000);
                this.SetProgress(80, "E");
                System.Threading.Thread.Sleep(1000);
            }
        }
    }
}

See Also