Exemple #1
0
 /// <summary>
 /// ThreadWorkDistribion is a workload-packages containing a subdived segment of work based on the workload divided by the amount of packages
 /// </summary>
 /// <param name="staticWorkloadExecutorIndexed">A (static) method that computes one workLoad-object at a time and provides the index of the array it origionally came from</param>
 /// <param name="workLoad">An array with objects you want to get computed by the executor</param>
 /// <param name="extraArgument">An extra Argument will be passed to the Executor if present</param>
 public ThreadWorkDistribution(ThreadWorkloadExecutorArgIndexed <T> workloadExecutorArgIndexed, T[] workLoad, object extraArgument, int startIndex, int endIndex)
 {
     this.workloadExecutorArgIndexed = workloadExecutorArgIndexed;
     this.workLoad      = workLoad;
     this.startIndex    = startIndex;
     this.endIndex      = endIndex;
     this.extraArgument = extraArgument;
 }
Exemple #2
0
 /// <summary>
 /// Helps spreading the same repetetive workload over multiple threads/cores in an easy way.
 /// Besides the workLoad-object, an extra Argument & the current index of the workLoad-array is passed to the Executor-delegate.
 /// </summary>
 /// <typeparam name="T">T: Generic-Type of the object you want to be computed by the executor</typeparam>
 /// <param name="staticWorkloadExecutor"> A (static) method that computes one workLoad-object at a time</param>
 /// <param name="workLoad">An array with objects you want to get computed by the executor</param>
 /// <param name="onComplete">Fired when all re-packaged workLoad-objects are finished computing</param>
 /// <param name="onPackageExecuted">Fires foreach finished re-packaged set of workLoad-object</param>
 /// <param name="maxThreads"> Lets you choose how many threads will be run simultaneously by the threadpool. Default: -1 == number of cores minus one, to make sure the MainThread has at least one Core to run on. (quadcore == 1 Core Mainthread, 3 cores used by the ThreadPoolScheduler)</param>
 /// <param name="scheduler">If Null, a new ThreadPoolScheduler will be instantiated.</param>
 /// <param name="safeMode">Executes all the computations within try-catch events, logging it the message + stacktrace</param>
 /// <returns>A ThreadPoolScheduler that handles all the repackaged workLoad-Objects</returns>
 public static ThreadPoolScheduler StartMultithreadedWorkloadExecution <T>(ThreadWorkloadExecutorArgIndexed <T> workloadExecutor, T[] workLoad, object extraArgument, MultithreadedWorkloadComplete <T> onComplete, MultithreadedWorkloadPackageComplete <T> onPackageComplete, int maxThreads = -1, ThreadPoolScheduler scheduler = null, bool safeMode = true)
 {
     return(MultithreadedWorkloadHelper.StartMultithreadedWorkloadExecution <ThreadWorkloadExecutorArgIndexed <T>, T>(workloadExecutor, workLoad, extraArgument, onComplete, onPackageComplete, maxThreads, scheduler, safeMode));
 }