本文整理汇总了C#中Channel.send方法的典型用法代码示例。如果您正苦于以下问题:C# Channel.send方法的具体用法?C# Channel.send怎么用?C# Channel.send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Channel
的用法示例。
在下文中一共展示了Channel.send方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SimpleHelloWorld
public void SimpleHelloWorld()
{
using (var ch = new Channel<string>())
{
Spawn.program(() => printStrings(ch, ""));
ch.send("Hello");
ch.send("World!");
}
}
示例2: sendStrings
void sendStrings(Channel<string> strings)
{
foreach (var i in Enumerable.Range(0, 50))
strings.send("str: " + i);
strings.Dispose();
}
示例3: sendIntegers
void sendIntegers(Channel<int> ints)
{
foreach (var i in Enumerable.Range(0, 50))
ints.send(i);
ints.Dispose();
}
示例4: OneSenderMultipleReceivers
public void OneSenderMultipleReceivers()
{
using (var ch = new Channel<string>())
{
Spawn.program(() => printStrings(ch, "A: "));
Spawn.program(() => printStrings(ch, "B: "));
for (int i = 0; i != 50; ++i)
ch.send(i.ToString());
}
}
示例5: MultipleSenderOneReceiver
public void MultipleSenderOneReceiver()
{
using (var ch = new Channel<string>())
{
var sigEnd = new Channel<bool>();
Spawn.program(() => printStrings(ch, ""));
Spawn.program(() => sendStrings(ch, sigEnd, "A: "));
Spawn.program(() => sendStrings(ch, sigEnd, "B: "));
for (int i = 0; i != 50; ++i)
ch.send(i.ToString());
bool x;
sigEnd.receive(out x);
sigEnd.receive(out x);
}
}
示例6: sendStrings
void sendStrings(Channel<string> strings, Channel<bool> sig, string prefix)
{
for (int i = 0; i!= 100; ++i)
strings.send(prefix + i);
sig.send(true);
}