How to determine page Processing Synchronus or Asynchronus?

Posted by Kasibabu under ASP.NET AJAX on 9/28/2011 | Points: 10 | Views : 2091 | Status : [Member] | Replies : 2
In my example
<asp:ScriptManager ID="ScriptManager1" runat="server">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:Timer ID="Timer1" runat="server" Interval="10000" ontick="Timer1_Tick">

the timer tick time is 10000 seconds for every 10 seconds page will be loaded again and again.....
but the question is for every 10 seconds page is loaded as synchronus or asynchrouns?

my code behind is
protected void Page_Load(object sender, EventArgs e)
if (Page.IsAsync)
Label2.Text = "page is Asynchrous processing...."; // for every aschronus request
Label2.Text = "page is Sychronus processing..."; // first time request only.
protected void Timer1_Tick(object sender, EventArgs e)
// for every 10 seconds tick even will be fired
if (ScriptManager1.IsInAsyncPostBack == true)
Label1.Text = DateTime.Now.ToString();
protected void Button1_Click(object sender, EventArgs e)
Label3.Text = "to cause postback to the server";
but Lable2.Text always shows
page is Sychronus processing... only.

and if i click on button(implictly postback) within 10 seconds it has to show Lable2.Text is Synchronus page porcessing
-------but not working.

Kasi babu


Posted by: Ndebata on: 10/3/2011 [Member] Starter | Points: 25

in page load to check async or normal post back, instead of Page.IsAsync

Kasibabu, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vishvvas on: 10/5/2011 [Member] [MVP] HonoraryPlatinum | Points: 25

Asynchronous or synchronous processing of page is more related to use of thread from thread pool. In case of astnchronous processing the thread for particular request is returned back to thread pool till the the operations is completed and a new thread is picked up for doing the further operation. Page is rendered after this. If the page is using IHttpAsyncHandler, then its is doing asynchronous operations. So one has to implement IHttpAsyncHandler and then only the page processing would be async or otherwise use following on Page_load
// Register async methods
new BeginEventHandler(BeginAsyncOperation),
new EndEventHandler(EndAsyncOperation)
One needs to put the operation intended for asynchronous in "BeginAsyncOperation" method.
Hope this helps.

Kasibabu, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response