Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why does FileHelpersAsyncEngine.Close dispose of the stream that is being written to? #434

Open
gregveres opened this issue Apr 24, 2024 · 0 comments

Comments

@gregveres
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant