In plain english eh...
The process of connecting to a web-page is multi-part. First, you establish a
request. Which
you are obviously doing. GetResponse and BeginGetResponse fire off this process
for you.
Now, GetResponse will hang your UI until you get a response from the server so
you'll want
to use the BeginGetResponse version.
That puts us to step 2. BeginGetResponse requires a call-back, which is where
you get your
RespCallback from. This method is called by the net classes when the data is
available. This
all happens on another thread and is thus asynchronous. This is great for you,
because after
your calling of BeginGetResponse your program can continue to interact with the
user.
That puts you to step 3. You are now in the callback method. IAsyncResult
identifies the
original call that you made. Remember here that many asynchronous operations can
be
happening at the same time (different threads) and that your callback method has
to
differentiate between them. IAsyncResult is also used by the net classes to
retrieve the
information associated with the entire call process. Serves a dual purpose and
is very
important.
At this point, you are still in the callback, on a different thread, and you can
choose to
end the request. This means getting the returned information and then figuring
some way
to display it back to the user. Remember, different thread still, so it isn't
potentially safe to
update the UI directly. You also wind up with another option, and that is where
your ReadCallBack
comes from. Not only do the net classes support the connection and response
process asynchronously
they also allow you to read the data back that the server is sending
asynchronously. This isn't
nearly as important for you as the first step. Instead forget about reading the
file asynchronously and
use the thread you are currently on to read the data synchronously. This is not
going to hose your
UI because you are on a separate thread from the UI thread.
In short:
BeginGetResponse -> Puts you on another thread
RespCallback -> Notifies you data is ready
IAsyncResult -> Uniquely identifies this request from others
ReadCallback -> Used to implement additional asynchronous processing of returned
data. Not really needed in most cases.