Very clearly , thanks :) 

-----邮件原件-----
发件人: [email protected] [mailto:[EMAIL PROTECTED] 代表 Michael Schwarz
发送时间: 2006年6月20日 14:56
收件人: Ajax.NET Professional
主题: [ajaxpro] What is the difference between asynchronous and synchronous calls?


Hi,

because we have a lot of questions concerning asynchronous and synchronous 
calls (on client-side JavaScript code) I will list some keywords here:

1) Asynchronous calls:

<script type="text/javascript">
function callback(res) {
    alert(res.value);
}
function invokeMyMethod() {
    Namespace.Classname.MyMethod(callback);
}
</script>

a) is the preferred way to call AjaxMethods from the client-side code
b) will not freeze web browser application (you are able to click around, move 
the window, or call another AjaxMethod
c) can use client-side timeouts to control what to do if requests needs longer 
than usual
d) a maximum of 2 concurrent requests are possible, and additional requests 
will be queued and started after one of the 2 concurrent requests is finished



2) Synchronous calls:

<scritp type="text/javascript">
function invokeMyMethod() {
    var res = Namespace.Classname.MyMethod();
    alert(res.value);
}
</script>


a) will freeze web browser application (on Internet Explorer the complete 
content can be invisible because during the request is running the display 
cannot be updated, you are not able to do other things on the same web page)
b) you have to wait until the request is finished, there is no way to abort the 
request
c) only one synchronous request at the same time possible




So, please use everytime the asynchronous call because it makes no sense to use 
the synchronous because of all the disadvantages.

--
Best regards | Schöne Grüße
Michael

Microsoft MVP - Most Valuable Professional Microsoft MCAD - Certified 
Application Developer

http://weblogs.asp.net/mschwarz/
http://www.schwarz-interactive.de/
mailto:[EMAIL PROTECTED]




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Ajax.NET Professional" group.

To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]

For more options, visit this group at http://groups.google.com/group/ajaxpro

The latest downloads of Ajax.NET Professional can be found at 
http://www.ajaxpro.info
-~----------~----~----~----~------~----~------~--~---

Reply via email to