本文整理汇总了C#中Channels.ClearAt方法的典型用法代码示例。如果您正苦于以下问题:C# Channels.ClearAt方法的具体用法?C# Channels.ClearAt怎么用?C# Channels.ClearAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Channels
的用法示例。
在下文中一共展示了Channels.ClearAt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: can_read_after_select_on_queued_Channels
public void can_read_after_select_on_queued_Channels()
{
var ch1 = new Channel<int>(1);
var ch2 = new Channel<bool>(1);
ThreadPool.QueueUserWorkItem(state => {
ch1.Send(123);
ch2.Send(true);
ch2.Close();
ch1.Send(124);
ch1.Close();
});
using (var select = new Channels(Op.Recv(ch1), Op.Recv(ch2))) {
var got = select.Select();
Debug.Print("got.Index = " + got.Index);
if (got.Index == 0) {
Assert.AreEqual(123, got.Value, "got.Value");
Assert.AreEqual(Maybe<bool>.Some(true), ch2.Recv());
}
else {
Assert.AreEqual(1, got.Index, "got.Index");
Assert.AreEqual(true, got.Value, "got.Value");
Assert.AreEqual(Maybe<int>.Some(123), ch1.Recv());
}
select.ClearAt(1);
got = select.Select();
Assert.AreEqual(0, got.Index, "got.Index, value =" + got.Value);
Assert.AreEqual(124, got.Value, "got.Value");
}
}
示例2: select_on_one_null_channel
public void select_on_one_null_channel()
{
var ch1 = new Channel<int>();
var ch2 = new Channel<bool>(2);
ch2.Send(true);
using (var select = new Channels(Op.Recv(ch1), Op.Recv(ch2))) {
select.ClearAt(0);
var got = select.Select();
Assert.AreEqual(1, got.Index, "expected any channel to return");
Assert.AreEqual(true, got.Value);
}
}