本文整理汇总了C#中BufferBlock.SignalAndWaitForCompletionAsync方法的典型用法代码示例。如果您正苦于以下问题:C# BufferBlock.SignalAndWaitForCompletionAsync方法的具体用法?C# BufferBlock.SignalAndWaitForCompletionAsync怎么用?C# BufferBlock.SignalAndWaitForCompletionAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BufferBlock
的用法示例。
在下文中一共展示了BufferBlock.SignalAndWaitForCompletionAsync方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LinkLeftToDemo
public static async Task LinkLeftToDemo()
{
var d1 = new BufferBlock<int>().ToDataflow(name: "IntGenerator");
var d2 = new ActionBlock<int>(s => Console.WriteLine(s)).ToDataflow();
var d3 = new ActionBlock<int>(s => Console.WriteLine(s)).ToDataflow();
var d4 = new ActionBlock<int>(s => Console.WriteLine(s + "[Left]")).ToDataflow();
d1.LinkTo(d2, _ => _ % 3 == 0);
d1.LinkTo(d3, _ => _ % 3 == 1);
d1.LinkLeftToError();//d1.LinkLeftTo(d4);
for (int i = 0; i < 10; i++)
{
d1.Post(i);
}
await d1.SignalAndWaitForCompletionAsync();
await d2.CompletionTask;
await d3.CompletionTask;
}
示例2: TransformAndLinkDemo
public static async Task TransformAndLinkDemo()
{
var d1 = new BufferBlock<int>().ToDataflow();
var d2 = new ActionBlock<string>(s => Console.WriteLine(s)).ToDataflow();
var d3 = new ActionBlock<string>(s => Console.WriteLine(s)).ToDataflow();
d1.TransformAndLink(d2, _ => "Odd: "+ _, _ => _ % 2 == 1);
d1.TransformAndLink(d3, _ => "Even: " + _, _ => _ % 2 == 0);
for (int i = 0; i < 10; i++)
{
d1.Post(i);
}
await d1.SignalAndWaitForCompletionAsync();
await d2.CompletionTask;
await d3.CompletionTask;
}