Showing posts with label asynch. Show all posts
Showing posts with label asynch. Show all posts

Monday, March 26, 2012

PageRequestManager only processes one asynch callback at a time?

I was under the impression that the asp.net ajax framework was capable of handling multiple asynch callbacks simultaneously and processing the results of each in the order that they come back. However, I accidentally discovered something interesting: it seems that if you begin an asynch callback from the browser while a previous asynch callback is still in process, the first one gets cancelled by the client-side PageRequestManager instance before it begins the second one.

To see what I'm talking about, you can go to this official MS ajax example:http://ajax.asp.net/docs/Samples/System.Web.UI.UpdateProgress1/cs/Default.aspx

Try clicking the first button, then quickly clicking the second button before the first date gets updated on the page. Notice that after a few seconds, the second date changes as a result of the second asynch callback, but the first date never gets updated. This is because the asp.net ajax framework is prematurely ending the first request as soon as you initiate the second request by clicking the second button.

I'm working on a project with multiple UpdatePanels on a page that do completely separate things in their server-side code, and ideally we would like the user to be able to initiate a callback in one panel and then immediately initiate a callback in the second panel, and have both of the asynchronous callbacks processing at the same time. At the moment, it doesn't seem like this is a possibility in the asp.net ajax framework.

If anybody can tell me how I might be able to get around this issue I would be very appreciative.

hello.

well, what you ask isn't doable with the current code of the platform. you can only have more than one remote call if you're using web services (and even in these cases you might face some problems which have been described here: http://www.codeproject.com/Ajax/aspnetajaxtips.asp)

PageRequestManager events being called too many times

I'm studying the PageRequestManager event lifecyle. It appears that when the number of times i click the linkbutton to perform the asynch postback, that same number of times the event is being called. Here's the scenario: I click the linkbutton once. Alerts for all events are called. I click the linkbutton once again. Alerts for all events are called twice. I click the linkbutton once again. Alerts for all events are called 3x. ... etc. Heres the sample code:

/*************************** aspx code ************************/

<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Scripts>
<asp:ScriptReference Path="AsynchronousLifeCycle.js" />
</Scripts>
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text="Date: "></asp:Label><br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Push me!" />
</ContentTemplate>
</asp:UpdatePanel>
</form>

/******** js code *************************************/

Sys.Application.add_load(ApplicationLoadHandler)
Sys.Application.notifyScriptLoaded();


function ApplicationLoadHandler(sender, args)
{
Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(InitializeRequest);
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequest);
Sys.WebForms.PageRequestManager.getInstance().add_pageLoading(PageLoading);
Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(PageLoaded);
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequest);
}

function InitializeRequest(sender, args)
{
alert("InitializeRequest");
}

function BeginRequest(sender, args)
{
alert("BeginRequest");
}

function PageLoading(sender, args)
{
alert("PageLoading");
}

function PageLoaded(sender, args)
{
alert("PageLoaded");
}

function PageLoaded(sender, args)
{
alert("PageLoaded");
}

function EndRequest(sender, args)
{
alert("EndRequest");
}

hi,

Please refer below URL:

http://ajax.asp.net/docs/ClientReference/Sys.WebForms/PageRequestManagerClass/PageRequestManagerBeginRequestEvent.aspx

Thanks

kishore

www.relgo.com.