I realize that it is probably been like this for quite some time, but I just ran into a case where I am trying to get some information from the underlying memory stream and it is crashing because the stream was closed when FileHelpersAsyncEngine was disposed.
I have a situation like this:
Outter function() {
using (var memory = new MemoryStream()) {
innerFunction(memory);
long length = memory.Length;
}
}
InnerFunction(Stream stream) {
var engine = new FileHelperAsyncEngine<MyType>();
using (engine.BeginWriteStream(stream))
{
engine.Close(); <= this closes the memory stream. Why?
}
}
I am wondering why the engine.Close() method closes the stream that was passed in? The stream that was passed in isn't owned by FileHelperAsyncEngine, so why should it try to clean it up?