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


C# ManualResetEventSlim.AssertWaitFor方法代码示例

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


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

示例1: Client_should_connect_to_server_and_signal_appropriate_callbacks

        public void Client_should_connect_to_server_and_signal_appropriate_callbacks()
        {
            var connected1 = new ManualResetEventSlim(false);
            var connected2 = new ManualResetEventSlim(false);

            var ex = ServerHelpers.CreateExecutor();
            var server = ServerHelpers.CreateServer();

            server.Connected.Subscribe(client =>
                {
                    connected1.Set();
                });

            server.Started.Subscribe(u =>
            {
                var client = new SocketClient(ex);
                client.Connected.Subscribe( _ =>
                    {
                        connected2.Set();
                    });
                client.Disconnected.Subscribe(exn =>
                    {
                        throw exn;
                    });
                client.Connect(new IPEndPoint(IPAddress.Loopback, server.BindEndPoint.Port));
            });

            server.Start();

            connected1.AssertWaitFor(5000);
            connected2.AssertWaitFor(5000);

            server.StopAndAssertStopped();
        }
开发者ID:wushian,项目名称:Stacks,代码行数:34,代码来源:RawBytesClientTests.cs

示例2: Client_should_signal_disconnection_when_server_is_closed

        public void Client_should_signal_disconnection_when_server_is_closed()
        {
            var disconnected = new ManualResetEventSlim();
            Utils.CreateServerAndClientProxy<TestActor, ITestActor>(out server, out clientProxy);

            clientProxy.Disconnected.Subscribe(exn => { disconnected.Set(); });
            
            server.Stop();

            disconnected.AssertWaitFor();
        }
开发者ID:wushian,项目名称:Stacks,代码行数:11,代码来源:ConnectionTests.cs

示例3: Starting_should_call_started_callback

            public void Starting_should_call_started_callback()
            {
                var started = new ManualResetEventSlim();
                var server = ServerHelpers.CreateServer();

                server.Started += () => { started.Set(); };
                server.Start();

                started.AssertWaitFor(2000);

                server.StopAndAssertStopped();
            }
开发者ID:Rush,项目名称:Stacks,代码行数:12,代码来源:SocketServerTests.cs

示例4: Starting_and_stopping_should_call_both_callbacks

            public void Starting_and_stopping_should_call_both_callbacks()
            {
                var started = new ManualResetEventSlim();
                var stopped = new ManualResetEventSlim();
                var server = ServerHelpers.CreateServer();

                server.Started.Subscribe(_ => { started.Set(); });
                server.Stopped.Subscribe(_ => { stopped.Set(); });

                server.Start();
                server.Stop();

                started.AssertWaitFor(2000);
                stopped.AssertWaitFor(2000);
            }
开发者ID:wushian,项目名称:Stacks,代码行数:15,代码来源:SocketServerTests.cs

示例5: When_exception_is_thrown_inside_callback_executor_should_signal_error

            public void When_exception_is_thrown_inside_callback_executor_should_signal_error()
            {
                var errOccured = new ManualResetEventSlim();

                var exec = new ActionBlockExecutor(null, new ActionBlockExecutorSettings());
                var server = ServerHelpers.CreateServer(exec);

                exec.Error += exc => { Assert.Equal("abcdef", exc.Message); errOccured.Set(); };
                server.Started += () => { throw new Exception("abcdef"); };

                server.Start();

                errOccured.AssertWaitFor(2000);

                server.Stop();
            }
开发者ID:Rush,项目名称:Stacks,代码行数:16,代码来源:SocketServerTests.cs

示例6: Calling_connect_twice_should_throw_an_exception

        public void Calling_connect_twice_should_throw_an_exception()
        {
            var hasConnected = new ManualResetEventSlim();
            var executor = ServerHelpers.CreateExecutor();
            var server = ServerHelpers.CreateServer(executor);

            server.Started.Subscribe(_ =>
            {
                Assert.Throws(typeof(InvalidOperationException),
                    () =>
                    {
                        var client = new SocketClient(executor);
                        client.Connect(server.BindEndPoint);
                        hasConnected.Set();
                        client.Connect(server.BindEndPoint);
                    });
            });

            server.Start();

            hasConnected.AssertWaitFor();
        }
开发者ID:wushian,项目名称:Stacks,代码行数:22,代码来源:RawBytesClientTests.cs

示例7: If_server_closes_then_client_should_raise_disconnect_event

        public void If_server_closes_then_client_should_raise_disconnect_event()
        {
            var disconnectedCalled = new ManualResetEventSlim();

            SocketServer server;
            SocketClient serverClient, remoteClient;

            ServerHelpers.CreateServerAndConnectedClient(out server, out serverClient, out remoteClient);

            remoteClient.Disconnected.Subscribe(exn =>
            {
                Assert.IsType(typeof(SocketException), exn);
                Assert.Equal((int)SocketError.Disconnecting, ((SocketException)exn).ErrorCode);
                disconnectedCalled.Set();
            });

            serverClient.Disconnected.Subscribe(exn =>
                {

                });
            server.Stop();
            serverClient.Close();

            disconnectedCalled.AssertWaitFor(5000);
        }
开发者ID:wushian,项目名称:Stacks,代码行数:25,代码来源:RawBytesClientTests.cs

示例8: If_client_cannot_connect_if_should_raise_disconnect_event_with_connection_refused_error

        public void If_client_cannot_connect_if_should_raise_disconnect_event_with_connection_refused_error()
        {
            var disconnectedCalled = new ManualResetEventSlim();

            var executor = ServerHelpers.CreateExecutor();
            var client = new SocketClient(executor);

            client.Disconnected.Subscribe(exn =>
                {
                    Assert.IsType(typeof(SocketException), exn);
                    Assert.Equal((int)SocketError.ConnectionRefused, ((SocketException)exn).ErrorCode);
                    disconnectedCalled.Set();
                });

            client.Connect(new IPEndPoint(IPAddress.Loopback, 45232));
            disconnectedCalled.AssertWaitFor();
        }
开发者ID:wushian,项目名称:Stacks,代码行数:17,代码来源:RawBytesClientTests.cs

示例9: CreateServerAndConnectedClient

        public static void CreateServerAndConnectedClient(out SocketServer server,
            out SocketClient client1, out SocketClient client2)
        {
            var connected1 = new ManualResetEventSlim(false);
            var connected2 = new ManualResetEventSlim(false);

            var ex = ServerHelpers.CreateExecutor();
            var s = ServerHelpers.CreateServer();

            SocketClient lClient = null;
            SocketClient sClient = null;

            s.Connected.Subscribe(c =>
            {
                sClient = c;
                connected2.Set();
            });

            s.Started.Subscribe(_ =>
            {
                var c = new SocketClient(ex);
                c.Connected.Subscribe(u =>
                {
                    lClient = c;
                    connected1.Set();
                });
                c.Connect(new IPEndPoint(IPAddress.Loopback, s.BindEndPoint.Port));
            });

            s.Start();

            connected1.AssertWaitFor(3000);
            connected2.AssertWaitFor(3000);

            server = s;
            client1 = lClient;
            client2 = sClient;
        }
开发者ID:wushian,项目名称:Stacks,代码行数:38,代码来源:Utils.cs

示例10: StopAndAssertStopped

 public static void StopAndAssertStopped(this SocketServer server)
 {
     var stopped = new ManualResetEventSlim(false);
     server.Stopped.Subscribe(_ =>
     {
         stopped.Set();
     });
     server.Stop();
     stopped.AssertWaitFor(3000);
 }
开发者ID:wushian,项目名称:Stacks,代码行数:10,代码来源:Utils.cs


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