public void TestDispose() { var stm = new PooledMemoryStream(); stm.Write(new byte[] { 1, 2, 3, 4 }, 0, 4); stm.Dispose(); stm.Write(new byte[] { 1, 2, 3, 4 }, 0, 4); stm.Dispose(); }
private async ValueTask Receive() { var buffer = new PooledMemoryStream(); Message message; try { await Receive(buffer, WireHeader.Size).ConfigureAwait(false); buffer.Position = 0; WireHeader wireHeader = WireHeader.ReadFrom(buffer); buffer.Reset(); await Receive(buffer, wireHeader.PayloadSize.Value).ConfigureAwait(false); buffer.Position = 0; message = new Message(wireHeader.MessageHeader, buffer); } catch (Exception ex) { if (!(ex is OperationCanceledException)) { //if (_logger.IsEnabled(LogLevel.Error)) //{ // _logger.LogError(ex, "Error during receive"); //} } //if(ex is SocketException sex && sex.ErrorCode == SocketError.TimedOut) buffer.Dispose(); return; } _session.EnqueueIncoming(message); }