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 8953471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:06:08+00:00 2026-06-15T14:06:08+00:00

I have a function which have a long execution time. public void updateCampaign() {

  • 0

I have a function which have a long execution time.

 public void updateCampaign()
    {

        context.Session[processId] = "0|Fetching Lead360 Campaign";
        Lead360 objLead360 = new Lead360();
        string campaignXML = objLead360.getCampaigns();

        string todayDate = DateTime.Now.ToString("dd-MMMM-yyyy");
        context.Session[processId] = "1|Creating File  for Lead360 Campaign on " + todayDate;
        string fileName = HttpContext.Current.Server.MapPath("campaigns") + todayDate + ".xml";
        objLead360.createFile(fileName, campaignXML);

        context.Session[processId] = "2|Reading The latest Lead360 Campaign";
        string file = File.ReadAllText(fileName);

        context.Session[processId] = "3|Updating Lead360 Campaign";
        string updateStatus = objLead360.updateCampaign(fileName);
        string[] statusArr = updateStatus.Split('|');
        context.Session[processId] = "99|" + statusArr[0] + " New Inserted , " + statusArr[1] + " Updated , With " + statusArr[2] + " Error , ";
    }

So to track the Progress of the function I wrote a another function

public void getProgress()
    {
        if (context.Session[processId] == null)
        {
            string json = "{\"error\":true}";
            Response.Write(json);
            Response.End();
        }else{
            string[] status = context.Session[processId].ToString().Split('|');
            if (status[0] == "99") context.Session.Remove(processId);

            string json = "{\"error\":false,\"statuscode\":" + status[0] + ",\"statusmsz\":\"" + status[1] + "\" }";
            Response.Write(json);
            Response.End();  
        }
    }

To call this by jQuery post request is used

reqUrl = "AjaxPages/lead360Campaign.aspx?processid=" + progressID + "&action=updatecampaign";
$.post(reqUrl);
setTimeout(getProgress, 500);

get getProgress is :

function getProgress() {
    reqUrl = "AjaxPages/lead360Campaign.aspx?processid=" + progressID + "&action=getProgress";
    $.post(reqUrl, function (response) {
        var progress = jQuery.parseJSON(response);
        console.log(progress)
        if (progress.error) {
            $("#fetchedCampaign .waitingMsz").html("Some error occured. Please try again later.");
            $("#fetchedCampaign .waitingMsz").css({ "background": "url(common/images/ajax_error.jpg) no-repeat center 6px" });
            return;
        }
        if (progress.statuscode == 99) {
            $("#fetchedCampaign .waitingMsz").html("Update Status :"+ progress.statusmsz );
            $("#fetchedCampaign .waitingMsz").css({ "background": "url(common/images/ajax_loded.jpg) no-repeat center 6px" });
            return;
        }
        $("#fetchedCampaign .waitingMsz").html("Please Wait... " + progress.statusmsz);
        setTimeout(getProgress, 500);
    });
}

But the problem is that I can’t see the intermediate message. Only the last message is been displayed after a long lime of ajax loading message

Also on the browser console I just see that after a long time first requested is completed and after that the second request is completed. but there should be for getProgress ?

I have checked jquery.doc and it says that $post is an asynchronous request.

Can anyone please explain what is wrong with the code or logic?

  • 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-15T14:06:10+00:00Added an answer on June 15, 2026 at 2:06 pm

    You are in a situation discussed here:

    ASP.net session request queuing

    While a request for a given user’s session is processed, other requests for the same session are waiting. You need to run your long function in a background thread and let the request that initiates it finish. However, the background thread will not have access to session, and you will need a different mechanism to communicate its progress.

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

Sidebar

Related Questions

I have a SQL-Statement which uses a Check-Function which takes a quite long time
I have a JavaScript function which is quite long and performs a number of
I have a function which can vary in the time it takes to finish.
I have a JavaScript function buildTable which builds a very long HTML table. function
hi i have function which is called by tinker listbox so i cannot return
Can I´m asking for advice. I have function which should return javascript object function
I have a function which looks something like this, it returns a noncopyable class
I have a function which I have to loop it a few times but
I have a function which takes two arguments, the ID of an item (wine)
I have a function which takes several boolean template arguments: template<bool par1, bool par2,

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.