static void Main90(string[] args) { // create a random number source Random rnd = new Random(); // create the source data WorkItem[] sourceData = new WorkItem[10000]; for (int i = 0; i < sourceData.Length; i++) { sourceData[i] = new WorkItem() { WorkDuration = rnd.Next(1, 11) }; } // created the contextual partitioner Partitioner <WorkItem> cPartitioner = new ContextPartitioner(sourceData, 100); // create the parallel Parallel.ForEach(cPartitioner, item => { // perform the work item item.performWork(); }); // wait for input before exiting Console.WriteLine("Press enter to finish"); Console.ReadLine(); }
public ChunkEnumerator(ContextPartitioner parent) { parentPartitioner = parent; }
public EnumerableSource(ContextPartitioner parent) { parentPartitioner = parent; }