In order to develop applications that target the embedded job scheduler, you must perform these steps.

After you have setup your environment, consider completing the Programmer's Guide to learn how to submit and run your jobs.

Important

A note about the help system and the code snippets. For simplicity and brevity, most of the code snippets in the help system use the ClusterJobScheduler as the job scheduler instead of having a separate snippet that targets the embedded job scheduler. You can easily replace the ClusterJobScheduler with EmbeddedJobScheduler. For most of the examples, that is all it takes to convert the example to use the embedded job scheduler.

Setting up your environment for the embedded job scheduler, consists of the following:

Setup Visual Studio project and add necessary assemblies

The only step necessary to use the Embedded Job Scheduler is to setup a Visual Studio project properly. Setting up the project for the Embedded Job Scheduler can be error prone, so look at the EmbeddedJobSchedulerTemplate example available in the SDK.

Step 1) In Visual Studio, create a new Visual C# or Visual Basic project. Make sure to target .NET 3.5 or greater.

Visual Studio Project Setup

Step 2) Add the three necessary references: AGI.Parallel.Client.dll, AGI.Parallel.EmbeddedClient.dll, AGI.Parallel.Infrastructure.dll

Embedded Add Required Assemblies
Caution

For .NET 4.0 or greater, the API requires Full Target. By default, Visual Studio may set the default target to Client Profile Only These errors and warnings may be displayed:

Dot Net Profile Only Warning

To fix this, set the target framework to .NET Framework 4 or .NET Framework 3.5

Dot Net Profile Specify Framework

Step 3) Add a build step to copy the necessary files needed by the embedded job scheduler to the bin folder of the executable. There are a number of ways to do this. One way is to add the files by "Content". Another way is to add a post-build step that copies the files. Copy the following files: AGI.Parallel.Host.exe, AGI.Parallel.Host.exe.config, AGI.Parallel.Host_x86.exe, AGI.Parallel.Host_x86.exe.config, log4net.dll. Make sure to add the files to Visual Studio as "Add as link"

Embedded Add Host Files As Link

After the files have been added to the solution, right click on each file and click on Properties. In the file properties page, change the "Copy to Output Directory" option from Do not copy to Copy if newer

Embedded Add Host Copy If Newer

Verify tasks can run

The final step is to make sure the host executables are properly placed in the location the embedded job scheduler expects. Replace the contents of Program.cs with the contents below. Compile and run. If you can run the program without any exceptions, congratulations! Everything is setup for developing applications for the embedded scheduler. Follow the programmer's guide to start coding!

C#  Copy imageCopy
using System;
using AGI.Parallel.Client;
using AGI.Parallel.Infrastructure;

namespace CodeSamples
{
    class Program
    {
        static void Main(string[] args)
        {
            using (IJobScheduler scheduler = new EmbeddedJobScheduler())
            {
                scheduler.Connect();
                Job job = scheduler.CreateJob();
                job.AddTask(new TestTask());
                job.Submit();
                job.WaitUntilDone();

                if (job.Tasks[0].TaskStatus == TaskStatus.Completed)
                {
                    Console.WriteLine("Congratulations, you can start coding!");
                }
                else
                {
                    Console.WriteLine("Something went wrong.");
                }
            }
        }

        [Serializable]
        class TestTask : Task
        {
            public override void Execute()
            {
                Console.WriteLine("Hello from Task!");
            }
        }
    }
}

See Also

Other Resources