コード例 #1
0
        public void AsyncCallbackReceiveTest()
        {
            var sentAsync = Task.Run(async() => { await Task.Delay(20); ipv4ServerClient.Send(TestData.GetDummyStream().ToArray()); });

            byte[] received             = null;
            ManualResetEventSlim mevent = new ManualResetEventSlim(false);

            ipv4Client.ReceiveAsync((buffer) =>
            {
                received = buffer;
                mevent.Set();
            });
            mevent.Wait(1000);
            Assert.IsNotNull(received);
            Assert.IsTrue(received.Length > 0);
        }
コード例 #2
0
        public async Task AsyncTaskReceiveTest()
        {
            var sentAsync = Task.Run(async() => { await Task.Delay(20); ipv4ServerClient.Send(TestData.GetDummyStream().ToArray()); });

            byte[] buffer = await ipv4Client.ReceiveAsync();

            Assert.IsNotNull(buffer);
            Assert.IsTrue(buffer.Length > 0);
        }