Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. PageAsyncTask with Multiple Page Requests

PageAsyncTask with Multiple Page Requests

Scheduled Pinned Locked Moved C#
csharpdotnettutorial
1 Posts 1 Posters 4 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Member_14718384
    wrote on last edited by
    #1

    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);
        }
    
    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups