BUG: MemoryStream.BeginWrite lies about completing synchronously

P

piersh

here's the deal:

In .NET 1.1, the default implementation of Stream.BeginWrite (which
MemoryStream does not override) returns an IAsyncResult whose
'CompletedSynchronously' property returns 'True'.

However, it uses the asynchronous 'AsyncCallback.BeginInvoke' to invoke
the callback which probably won't have executed by the time the
BeginWrite call returns, and AFAICT there's no attempt to call, or
mechanism to let one call, the corresponding EndInvoke.

I was under the impression that 'CompletedSynchronously' implied that
the operation had completed and the callback (if any) had been called -
this is certainly the case for other types of streams.

It would seem to me that if a Stream.BeginXXXX method is going to
return 'CompletedSynchronously==true' it should either .Invoke the
callback synchronously, or, if it's invoking via .BeginInvoke, at least
call .EndInvoke either before returning, or in the corresponding
..EndXXXX method.

Or am I missing something here?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top