Click or drag to resize

Programmer's Guide

Here is a very simple example application. It adds two numbers together and writes the result to the console.

C#
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();
                Task task = new SimpleTask(1, 1);
                job.AddTask(task);
                job.Submit();
                job.WaitUntilDone();
                Console.WriteLine("Result = " + task.Result);
            }
        }

        [Serializable]
        public class SimpleTask : Task
        {
            private int a;
            private int b;

            public SimpleTask(int first, int second)
            {
                a = first;
                b = second;
            }

            public override void Execute()
            {
                Result = a + b;
            }
        }
    }
}

Copy and paste the code into a Visual Studio project, compile, and run. The application first connects and submits a task to the coordinator. Next, an agent will be assigned the work and execute the task in an isolated process. Finally, the result of the task is sent back to the client.

Step through the code in Visual Studio line by line. Examine the messages written from the coordinator and agent consoles. Take note of how the coordinator and agent respond after stepping through each line. For example, stepping past job.Submit will cause the coordinator console to log "added task to queue". What this means will be discussed later.

Step Through Code

Continue to experiment with this application. Try to add more tasks to the job, set the jobs's TaskEnvironment, or modify some of the job options. As this example shows, the basic structure and core pieces of an application written with the API are simple but powerful!

Next Steps

With a rudimentary example application finished, explore the help system and move on to more advanced topics. The following sections give various topics in the API more treatment.

Title

Read this if you want to...

Tutorial

Read a step by step narrative of another sample application.

How To

Get solutions to common patterns in the API.

Key concepts

Understand the key concepts and building blocks of the product.

Debugging

Get instructions on how to step through the remote task code.

Frequently Asked Questions

Get answers to frequently asked questions.

Internals

Gain a firm understanding of the internals of the product.

Library Reference

Explore what is available in the API.

STK Parallel Computing Server 2.9 API for .NET