public static async Task Use() { const string exampleStr = "The pipeline pattern is the best pattern"; var mgPipeline = new TplAsyncPipelineBuilder <string>() .AddStep(str => FindMostCommonAsync(str)) .AddStep(str => CountChars(str)) .AddStep(len => IsOdd(len)) .Build(); var result = await mgPipeline.Execute(exampleStr); Console.WriteLine($"MG pipeline: {result}"); }
private static async Task TplDataflowPipeline() { var pipeline = new TplAsyncPipelineBuilder <string, bool>() .AddStep(str => Utils.FindMostCommon(str)) .AddStep(word => Utils.CountChars(word)) .AddStep(length => Utils.IsOdd(length)) .Build(); const string sentence = "The pipeline pattern is the best pattern"; Console.WriteLine($"Pipeline executed. Sentence: {sentence}"); var result = await pipeline.Execute(sentence); Console.WriteLine($"Is most common word odd? {result.ToString()}."); }