Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7935487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:56:15+00:00 2026-06-03T21:56:15+00:00

A common task I have to do for a site I work on is

  • 0

A common task I have to do for a site I work on is the following:

  • Download data from some third-party API
  • Process the data in some fashion
  • Display the results on the page

I was initially using WebClient.DownloadStringAsync and doing my processing on the result. However I was finding that DownloadStringAsync was not respecting the AsyncTimeout parameter, which I sort of expected once I did a little reading about how this works.

I ended up adapting the code from the example on how to use PageAsyncTask to use DownloadString() there – please note, it’s the synchronous version. This is probably okay, because the task is now asynchronous. The tasks now properly time out and I can get the data by PreRender() time – and I can easily genericize this and put it on any page I need this functionality.

However I’m just worried it’s not ‘clean’. The page isn’t notified when the task is done like the DownloadStringAsync method would do – I just have to scoop the results (stored in a field in the class) up at the end in my PreRender event.

Is there any way to get the Webclient’s Async methods to work with RegisterPageTask, or is a helper class the best I can do?

Notes: No MVC – this is vanilla asp.net 4.0.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T21:56:17+00:00Added an answer on June 3, 2026 at 9:56 pm

    If you want an event handler on your Page called when the async task completes, you need only hook one up. To expand on the MSDN “how to” article you linked:

    1. Modify the “SlowTask” class to include an event, like – public event EventHandler Finished;
    2. Call that EventHandler in the “OnEnd” method, like – if (Finished != null)
      {
      Finished(this, EventArgs.Empty);
      }
    3. Register an event handler in your page for SlowTask.Finished, like – mytask.Finished += new EventHandler(mytask_Finished);

    Regarding ExecuteRegisteredAsyncTasks() being a blocking call, that’s based only on my experience. It’s not documented explicitly as such in the MSDN – http://msdn.microsoft.com/en-us/library/system.web.ui.page.executeregisteredasynctasks.aspx

    That said, it wouldn’t be all that practical for it be anything BUT a blocking call, given that it doesn’t return a WaitHandle or similar. If it didn’t block the pipeline, the Page would render and be returned to the client before the async task(s) completed, making it a little difficult to get the results of the task back to the client.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a common task that I do with some Activities - downloading data
Here's a common, simple task: Read configuration settings from a configuration file, save the
Common situation: I have a client on my server who may update some of
I have a service component (common task for all my apps), which can be
I have a task to edit some content for a footer being used in
This is Common task In PHP and other programming languages.I moved from PHP developer.
I have to send information too a third party in an XML format they
I have tabular data with the following fields constituting a record: SourceID SourceLabel SourceGroupID
I have a data flow component, comprise of the following : 1.) Read Excel
I think it's common task. I have about 2400 raws in database with titles

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.