PageAsyncTask with Multiple Page Requests
C#
1
Posts
1
Posters
4
Views
1
Watching
-
Hi all, I'm having some issues with PageAsyncTask and BeginInvoke on with ASPX .NET framework 4.0. It doesn't seem to work with multiple requests to the page. The Page_PreRenderComplete event gets confused between the requests. The final rendered page doesn't synchronize with the original page request. For example, if the browser requests the page, and then another request is made to the page, the images downloaded in the second request replace the images from the first request. The variables from the second request also replace the data in the first request.
PageAsyncTask taskDownloadImages = new PageAsyncTask(BeginImageDownload, EndImageDownload, null, null, true); Page.RegisterAsyncTask(taskDownloadImages); ExecuteRegisteredAsyncTasks(); IAsyncResult BeginImageDownload(object sender, EventArgs e, AsyncCallback cb, object state) { \_func = new AsyncTaskDelegate(AsyncTaskDownloadImages); IAsyncResult result = \_func.BeginInvoke(cb, state); return result; } public void AsyncTaskDownloadImages() { for (int i = 0; i < maxResults; ++i) { DownloadImage2(sortedProducts\[i\].imageUrlHiRes, tempImageFolderRandomName + i); } } void EndImageDownload(IAsyncResult ar) { \_func.EndInvoke(ar); }