public override int Read(byte[] buffer, int offset, int size) { if (_timeout <= 0) { return(_port.Read(buffer, offset, size)); } else { IAsyncResult ar = _port.BeginRead(buffer, offset, size, null, null); if (_timeout > 0 && !ar.IsCompleted) { ar.AsyncWaitHandle.WaitOne(_timeout, false); if (!ar.IsCompleted) { throw new RemotingTimeoutException(); } } return(_port.EndRead(ar)); } } // Read