コード例 #1
0
        public static async Task RunAsync(int inputSize)
        {
            var pipeline = new DataflowPipeline();

            Console.WriteLine("Sending input messages to pipeline...");
            var sw = new Stopwatch();

            sw.Start();

            // var generatedStrings = new string[inputSize];
            var inputCmd = new Tuple <int, int>(1024, 512);

            for (var i = 0; i < inputSize; i++)
            {
                pipeline.entryBlock.Post(inputCmd);
            }

            //var inputTasks = generatedStrings.Select(s => pipeline.entryBlock.SendAsync(s));
            //generatedStrings = null;
            //await Task.WhenAll(inputTasks).ConfigureAwait(false);
            pipeline.entryBlock.Complete();
            await pipeline.finalBlock.Completion.ConfigureAwait(false);

            sw.Stop();

            Console.WriteLine("Done. Time elapsed: {0} ms", sw.Elapsed.TotalMilliseconds);
            Console.WriteLine("Pipeline complete. Number of results: {0}", pipeline.result.Count);
        }
コード例 #2
0
        private static async Task MainAsync(string[] args)
        {
            // warming up
            Console.WriteLine("Warming up...");
            //await DataflowPipeline.RunAsync(200).ConfigureAwait(false);
            DataflowPipeline.RunWithoutPipeline(200);
            Console.WriteLine("Done. Starting pipeline...");

            // await DataflowProducerConsumer.RunAsync().ConfigureAwait(false);
            //await DataflowPipeline.RunAsync(400).ConfigureAwait(false);
            DataflowPipeline.RunWithoutPipeline(400);

            Console.WriteLine("Press enter to exit...");
            Console.ReadLine();
        }