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

  • SEARCH
  • Home
  • 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 5941297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:05:24+00:00 2026-05-22T16:05:24+00:00

I’ve got a page that generates a bunch of reports, and emails a zip

  • 0

I’ve got a page that generates a bunch of reports, and emails a zip of the results. This process takes about 30sec to 2min.

When the user invokes this process via ajax, I can poll the web service via ajax to get the results, but how do I create an async method that will continuously update a variable?

For simplicity, how could I write a method that would count from 1 to 1 million and add each number to a list, and at the same time be able to poll the web service and return the current number of items in said list?

Any articles would be appreciated also.

  • 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-05-22T16:05:25+00:00Added an answer on May 22, 2026 at 4:05 pm

    First, some background thoughts:

    1) Since it’s a long running job, you may want a cache of previously executed jobs so that you aren’t duplicating work and overburdening your server.

    2) You shouldn’t have to start a separate background thread, since each ASP.NET request is going to be executing in it’s own thread anyway. However, if you find you are starving your ASP.NET worker process, you can make your web methods asynchronous on the server side – see: this article.

    The implementation requires three components – a cache, a webmethod to run the job, and a web method to check job status. You will also need to be able to generate a key that allows the system to track requests. You can generate this server side (when you generate the page), or client side (if you have a clever algorithm that can generate unique ids).

    The cache can be application scoped if you want users to be able to share running jobs, or session scoped if you don’t. The cache is simply a dictionary that holds references to your running job instances.

    A simple example (this won’t compile, probably contains syntax errors, and is intended mostly to get the point across).

    Server pseudo code:

    //In application Session_Start, 
    Session["ReportCache"] = new Dictionary<string, ReportStatus>();
    
    public class ReportResults
    {
    }
    
    public class ReportStatus
    {
        public int PercentComplete = 0;
    }
    
    [WebMethod(EnableSessions = true)]
    ReportResults RunReport(string uniqueid)
    {
        ReportStatus status = new ReportStatus();
        Session["ReportStatus"].Add(uniqueid, status);
        //Start report
        for(int i = 0; i < 100000; ++i)
        {
    
            //update the report status
            status.PercentComplete = 100 * 100000 * i / 100000;
        }
        Session["ReportStatus"].Remove(uniqueid);
    
    }
    
    [WebMethod(EnableSessions=true)]
    public ReportStatus GetStatus(uniqueid)
    {
        try
        {
            return Session["ReportStatus"][uniqueid];
        }
        catch(Exception)
        {
            return null;
        }
    }
    

    On the client, use ajax to call the first web method. It won’t call the onSuccess callback until the report is finished. Use setTimeout to periodically poll the second web method to get status information and update the client. When the first web method completes, cancel your timer.

    Your biggest problem is going to be the fact that your server is going to be running lots of long running jobs, which can degrade overall performance and responsiveness. You might want to take a different approach altogether. For instance, rather than running the reports on demand per user, you can queue up the list of people who want to receive the report – then, once an hour/day/week (whatever) you can have a separate process run the report once and send it out.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I know there's a lot of other questions out there that deal with this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the

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.