当前位置: 首页>>代码示例>>C#>>正文


C# ConcurrentBag.Single方法代码示例

本文整理汇总了C#中ConcurrentBag.Single方法的典型用法代码示例。如果您正苦于以下问题:C# ConcurrentBag.Single方法的具体用法?C# ConcurrentBag.Single怎么用?C# ConcurrentBag.Single使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ConcurrentBag的用法示例。


在下文中一共展示了ConcurrentBag.Single方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: should_not_filter_received_messages_when_environment_is_not_specified

        public void should_not_filter_received_messages_when_environment_is_not_specified()
        {
            var transport1 = CreateAndStartZmqTransport(environment: null);

            var transport2ReceivedMessages = new ConcurrentBag<TransportMessage>();
            var transport2 = CreateAndStartZmqTransport(onMessageReceived: transport2ReceivedMessages.Add, environment: "NotTest");
            var transport2Peer = new Peer(new PeerId("Abc.Testing.2"), transport2.InboundEndPoint);

            var message = new FakeCommand(1).ToTransportMessage();
            transport1.Send(message, new[] { transport2Peer });

            Wait.Until(() => transport2ReceivedMessages.Count >= 1, 500.Milliseconds());
            transport2ReceivedMessages.Single().Id.ShouldEqual(message.Id);
        }
开发者ID:MarouenK,项目名称:Zebus,代码行数:14,代码来源:ZmqTransportTests.cs

示例2: should_not_dispatch_messages_received_from_wrong_environment

        public void should_not_dispatch_messages_received_from_wrong_environment()
        {
            var transport1ReceivedMessages = new ConcurrentBag<TransportMessage>();
            var transport1 = CreateAndStartZmqTransport(onMessageReceived: transport1ReceivedMessages.Add);

            var transport2ReceivedMessages = new ConcurrentBag<TransportMessage>();
            var transport2 = CreateAndStartZmqTransport(onMessageReceived: transport2ReceivedMessages.Add, environment: "NotTest");
            var transport2Peer = new Peer(new PeerId("Abc.Testing.2"), transport2.InboundEndPoint);

            var message1 = new FakeCommand(1).ToTransportMessage();
            var message2 = new FakeCommand(2).ToTransportMessage();
            transport1.Send(message1, new[] { transport2Peer }); // should not arrive

            Thread.Sleep(500); //:(
            transport2.Configure(transport2Peer.Id, _environment);
            transport1.Send(message2, new[] { transport2Peer }); //should arrive

            Wait.Until(() => transport2ReceivedMessages.Count >= 1, 500.Milliseconds());
            transport2ReceivedMessages.Single().Id.ShouldEqual(message2.Id);
        }
开发者ID:Julion,项目名称:Zebus,代码行数:20,代码来源:ZmqTransportTests.cs


注:本文中的ConcurrentBag.Single方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。