public MemoryStreamWrapper GetStreamWrapper() { NoClosingMemoryStream returnStream; if (!_streams.TryDequeue(out returnStream)) { returnStream = new NoClosingMemoryStream(); } return(new MemoryStreamWrapper( returnStream, _streams )); }
public MemoryStreamWrapper( NoClosingMemoryStream ms, ConcurrentQueue <NoClosingMemoryStream> addOnExit ) { if (ms == null) { throw new ArgumentNullException( MyNameof.GetLocalVarName(() => ms)); } if (addOnExit == null) { throw new ArgumentNullException( MyNameof.GetLocalVarName(() => addOnExit)); } _addOnExit = addOnExit; _ms = ms; }