Ejemplo n.º 1
0
        public void TestWasFalse()
        {
            var boolean = new AtomicBool();

            if (boolean.WasFalse())
            {
                if (boolean.WasFalse())
                {
                    Assert.Fail("AtomicBool should be true until SetFalse is called");
                }

                boolean.SetFalse();

                if (boolean.WasFalse())
                {
                    Assert.Pass();
                }
                else
                {
                    Assert.Fail("AtomicBool should be reset by calling SetFalse");
                }
            }
            else
            {
                Assert.Fail("AtomicBool should be false when initialized");
            }
        }
Ejemplo n.º 2
0
        public virtual void ProcessReceive(SocketAsyncEventArgs e)
        {
            flagReceiving.SetFalse();

            if (e.BytesTransferred > 0 && e.SocketError == SocketError.Success)
            {
                OnReceived(e.Buffer, e.Offset, e.BytesTransferred);
            }
            else
            {
                Disconnect(CloseReason.RemoteClose);
                return;
            }

            LastActiveTime = DateTime.Now;

            StartReceive();
        }