JobAdditionalDependencies Property |
Namespace: AGI.Parallel.Client
using System; using System.Collections.Generic; using System.IO; using System.Reflection; 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(); List<string> assemblyNames = new List<string>(); // For instance, let's just send all the assemblies in a directory. // Real-world examples include working with Microsoft's Managed Extensibility Framework, which may not reference your assemblies automatically. foreach (string file in Directory.GetFiles("C:\\LocationOfAssemblies", "*.dll", SearchOption.TopDirectoryOnly)) { Assembly assembly = Assembly.LoadFile(file); assemblyNames.Add(assembly.FullName); job.AdditionalDependencies.Add(assembly); } job.AddTask(new PrintAssembliesInTask { AssemblyNames = assemblyNames } ); job.Submit(); job.WaitUntilDone(); Console.WriteLine("The assemblies the task printed:"); Console.WriteLine(job.Tasks[0].StandardOutput); } /* * The output of the application should resemble: * The assemblies the task printed: * ICSharpCode.SharpZipLib, Version=0.86.0.518, Culture=neutral, PublicKeyToken=1b03e6acf1164f73 * Microsoft.Practices.ObjectBuilder2, Version=2.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 * Microsoft.Practices.Unity.Configuration, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 * Microsoft.Practices.Unity, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 * White.Core, Version=0.2.0.0, Culture=neutral, PublicKeyToken=2672efbf3e161801 * White.NUnit, Version=0.2.0.0, Culture=neutral, PublicKeyToken=2672efbf3e161801 * Xstream.Core, Version=1.0.3552.35177, Culture=neutral, PublicKeyToken=5a34ce33a538d84f */ } [Serializable] public class PrintAssembliesInTask : Task { public List<string> AssemblyNames { get; set; } public override void Execute() { // Your assemblies will be sent to the host. // This task demonstrates getting a reference to the Assembly type. foreach (string assemblyName in this.AssemblyNames) { Assembly assembly = Assembly.Load(assemblyName); Console.WriteLine(assembly.FullName); } } } } }
STK Parallel Computing Server 2.9 API for .NET