Created
October 5, 2012 18:16
-
-
Save ElemarJR/3841453 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static void Main(string[] args) | |
| { | |
| Console.Title = "TPL Dataflow"; | |
| var source = new[] { | |
| "elemarjr", "leandronet", "vquaiato", | |
| "juanplopes", "rodrigovidal", "cleytonferrari", | |
| "diogodamiani", "sricanesh", "rodrigokono" | |
| }; | |
| var ab = new ActionBlock<string>(async s => | |
| { | |
| await Task.Delay(200); | |
| Console.WriteLine(s); | |
| }); | |
| var tb = new TransformBlock<string, string>(s => | |
| { | |
| return s.ToUpper(); | |
| }); | |
| tb.LinkTo(ab); | |
| var tb2 = new TransformBlock<string, string>(s => | |
| { | |
| return new string(s.Reverse().ToArray()); | |
| }); | |
| tb2.LinkTo(tb); | |
| foreach (var item in source) | |
| tb2.Post(item); | |
| Console.WriteLine("Waiting..."); | |
| Console.Read(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment