Пример #1
0
        private static void UseSimple()
        {
            var pipeline = TPLDataflowPipelineSimple.CreatePipeline(resultCallback: res =>
            {
                Console.WriteLine(res);
                Console.WriteLine(Utils.GetThreadPoolThreadsInUse());
            });

            for (int i = 0; i < 50; i++)
            {
                pipeline.Post("The pipeline pattern is the best pattern");
            }
        }
Пример #2
0
        private static void UseSimpleAsync()
        {
            var pipeline = TPLDataflowPipelineSimple.CreatePipeline(resultCallback: res =>
            {
                Console.WriteLine(res);
                Console.WriteLine(Utils.GetThreadPoolThreadsInUse());
            });

            Task.Run(async() =>
            {
                for (int i = 0; i < 50; i++)
                {
                    await pipeline.SendAsync("The pipeline pattern is the best pattern");
                }
            });
        }