Asynchronous calls within a callback?

  • Thread starter Thread starter Guest
  • Start date Start date
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?
 
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,
 
Back
Top