Created
February 1, 2026 12:40
-
-
Save wullemsb/15c0773fe8850f040dba926189fb80b6 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
| var sourceBlock = new BufferBlock<string>(); | |
| var urgentBlock = new ActionBlock<string>(msg => Console.WriteLine($"URGENT: {msg}")); | |
| var normalBlock = new ActionBlock<string>(msg => Console.WriteLine($"Normal: {msg}")); | |
| var unhandledBlock = new ActionBlock<string>(msg => Console.WriteLine($"Unhandled: {msg}")); | |
| // Specific conditions first | |
| sourceBlock.LinkTo(urgentBlock, new DataflowLinkOptions { PropagateCompletion = true }, | |
| msg => msg.StartsWith("URGENT:")); | |
| sourceBlock.LinkTo(normalBlock, new DataflowLinkOptions { PropagateCompletion = true }, | |
| msg => msg.StartsWith("INFO:")); | |
| // Catch-all for everything else - no predicate | |
| sourceBlock.LinkTo(unhandledBlock, new DataflowLinkOptions { PropagateCompletion = true }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment