"景先生毕设|www.jxszl.com

C# Channel类代码示例

2023-12-29 17:43编辑: www.jxszl.com景先生毕设
本文整理汇总了C#中Channel类的典型用法代码示例。如果您正苦于以下问题:C#Channel类的具体用法?C#Channel怎么用?C#Channel使用的例子?这里精选的类代码示例或许可以为您提供帮助。 示例1:can_read_after_select_on_queued_Channels publicvoidcan_read_after_select_on_queued_Channels() { varch1=newChannel(1); varch2=newChannel(1); ThreadPool.QueueUserWorkItem(state=>{ ch1.Send(123); ch2.Send(true); ch2.Close(); ch1.Send(124); ch1.Close(); }); using(varselect=newChannels(Op.Recv(ch1),Op.Recv(ch2))){ vargot=select.Select(); Debug.Print("got.Index="+got.Index); if(got.Index==0){ Assert.AreEqual(123,got.Value,"got.Value"); Assert.AreEqual(Maybe.Some(true),ch2.Recv()); } else{ Assert.AreEqual(1,got.Index,"got.Index"); Assert.AreEqual(true,got.Value,"got.Value"); Assert.AreEqual(Maybe.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"); } }
原文链接:http://www.jxszl.com/biancheng/C/556724.html