By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,971 Members | 1,467 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,971 IT Pros & Developers. It's quick & easy.

Ajax.NET asynchronous call waits for first process to finish before executing second

Frinavale
Expert Mod 5K+
P: 9,731
I have a peculiar problem...

Background:

I have a function that I don't want the user to execute more than once while they are waiting for it to process; therefore, I disable all of the controls on the page via some JavaScript before the request is sent. This function takes some time to execute because it has to communicate with hardware that is rather slow. This slowness combined with a little bit of lag sometimes results in a Sys.WebForms.PageRequestManager TimeoutException. Since I disable all of the controls during this processing, and because this exception prevents the server responding to the browser, my web page becomes unusable.

To fix this problem I ended up writing a JavaScript function that enables the "Exit" button on the page and displays a message informing the user that there was a problem when ever a Ajax Exception occurs...(this has been implemented in a function that is attached to the EndRequest event for those of you who are curious).

So now my user has a way to exit the page when something goes wrong.

Scenario:

Consider the following Scenario

1. The user clicks the button that triggers the slow function to execute.
When this happens a time out exception is thrown, my JavaScript catches the exception, enables the Exit button and displays an error message
2. The user clicks the exit button

When the user clicks the exit button, another time out exception is thrown.....

Debugging this problem I placed a break point after the slow function finishes executing and a break point in the PageLoad of the aspx page.

When I click the exit button in step 2, the PageLoad event does not occur until After the slow function (triggered in step 1) has finished executing.



Could someone please explain to me why the first function has to finish executing before the second request can be processed?

It makes no sense to me why we would be given the ability to preform asynchronous calls to the server if the server cannot handle more than one request from a web browser.

Thanks in advance,

-Frinny
Jul 25 '08 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.