A Complete Example
The following is a complete example that shows how to use the Compute Cluster Pack (CCP) API to connect to a cluster, create a job, add a task to the job, and add the job to the scheduling queue.
Note that there are several locations in the example that you will need to provide cluster-specific information before compiling the code.
using System; using System.Collections.Generic; using System.Text; using Microsoft.ComputeCluster; // Reference ccpapi.dll namespace Complete { class Program { static void Main(string[] args) { ICluster cluster = new Cluster(); IJob job = null; ITask task = null; try { cluster.Connect("localhost"); job = cluster.CreateJob(); job.Name = "My Job"; task = cluster.CreateTask(); task.CommandLine = "dir %windir%"; task.Stdout = @"%userprofile%\windir_stdout.txt"; task.Stderr = @"%userprofile%\windir_stderr.txt"; job.AddTask(task); cluster.QueueJob(job, null, null, true, 0); } catch (Exception e) { Console.WriteLine(e.Message); } cluster.Dispose(); } } }
Related topics
Show: