Game Development Reference
state.FixedSizeBuffer = false;
state.DynamicBuffer = new List<byte>(bufferSize);
Retrieve the response object for the request so that data can now be read from the
Stream responseStream = response.GetResponseStream();
state.ResponseStream = responseStream;
Begin reading stream data asynchronously.
The following callback is used when an asynchronous data read occurs.
private void ReadCallback(IAsyncResult asyncResult)
Pull the asynchronous state object out of the result object.
AsyncFileDownloadState state =
Retrieve the ResponseStream from the state object that was set in the ResponseCallback .
Stream responseStream = state.ResponseStream;
Check if there is any more data to read.
int bytesRead = responseStream.EndRead(asyncResult);
if (bytesRead > 0)
Copy the temporary data buffer into the appropriate data buffer that holds the