Asynchronous calls within a callback?

G

Guest

In the .NET 2.0 example for HttpWebRequest.BeginGetResponse(), in the
RespCallback function, after EndGetResponse(), it gets the stream and starts
reading from it asynchronously. I'm wondering why. Since it's already
happening in a callback function, wouldn't it be just as good to do the read
synchronously?
 
J

Joerg Jooss

uncaged said:
In the .NET 2.0 example for HttpWebRequest.BeginGetResponse(), in the
RespCallback function, after EndGetResponse(), it gets the stream and
starts reading from it asynchronously. I'm wondering why. Since
it's already happening in a callback function, wouldn't it be just as
good to do the read synchronously?

This depends on your requirements. If you'd like to be able to cancel
an in-flight transmission, async I/O is the way to go.

As far as I remember in .NET 1.0 it was recommended not to mix sync and
async I/O, but this doesn't seem to be the case anymore.

Cheers,
 

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