Exemple #1
0
        static void Main(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 contentual 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();
        }
Exemple #2
0
 public ChunkEnumerator(ContextPartitioner parent)
 {
     parentPartitioner = parent;
 }
Exemple #3
0
 public EnumerableSource(ContextPartitioner parent)
 {
     parentPartitioner = parent;
 }