This is a migrated thread and some comments may be shown as answers.

Asynchrone

2 Answers 95 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Bruno
Top achievements
Rank 1
Bruno asked on 05 Apr 2012, 01:16 PM
I trying to reproduce this following scenario : I have 1 button(btnTest) outside an asp updatePanel, inside then i have 2 rad notifications, i have other as update panel with 2 radtextBox and 1 button(btnInsert), what i want is: i will click on the btnTest it will show 'Start Processing', and when done(after 8 seconds), appears 'Done!' (OK, this works), but lets suppose that i click on button, the Start Processing appears, and while the request running(doesnt appear 'Done!' yet), i click on the btnInsert, so i wanna the btnInsert, do what he need to do, and the request of btnTest keep running. Why my actual code doesnt work for that? Can someone point me to right direction, or help me provide a code?

thanzk
the asp code
<form id="form1" runat="server">
<telerik:RadScriptManager ID="Script" runat="server" />
<div id="divPrincipal">
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
            function Start() {
                var notification = $find('<%= RadNotification1.ClientID %>');
                notification.show();
            }
        </script>
    </telerik:RadCodeBlock>
    <telerik:RadButton ID="btnTeste" runat="server" Text="Teste" OnClick="btnTeste_Click" OnClientClicked="Start" />
    <asp:UpdatePanel ID="updNotificacao" UpdateMode="Conditional" runat="server" ChildrenAsTriggers="false">
        <ContentTemplate>
            <telerik:RadNotification ID="RadNotification1" runat="server" EnableRoundedCorners="true"
                EnableShadow="true" Text="Começou a Processar" Title="Mensagem" Width="300" Height="100" />
            <telerik:RadNotification ID="RadNotification2" runat="server" EnableRoundedCorners="true"
                EnableShadow="true" Text="Execucao Concluida" Title="Mensagem" Width="300" Height="100" />
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="btnTeste" EventName="Click" />
        </Triggers>
    </asp:UpdatePanel>
    <asp:UpdatePanel runat="server" ID="updForm" UpdateMode="Conditional" ChildrenAsTriggers="false">
        <ContentTemplate>
            <table>
                <tr>
                    <td>Codigo:</td>
                    <td>
                        <telerik:RadTextBox ID="txtNome" runat="server" TextMode="SingleLine" />
                    </td>
                </tr>
                <tr>
                    <td>Descricao:</td>
                    <td>
                        <telerik:RadTextBox ID="txtDescricao" runat="server" TextMode="SingleLine" />
                    </td>
                </tr>
                <tr>
                    <td>
                        <telerik:RadButton ID="btnInserir" Text="Inserir" runat="server" OnClick="btnInserir_Click" />
                        <asp:Label Text="" ID="lblResultado" runat="server" />
                    </td>
                </tr>
            </table>
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="btnInserir" EventName="Click" />
        </Triggers>
    </asp:UpdatePanel>
</div>
</form>

the .cs code
protected void btnTeste_Click(object sender, EventArgs e)
{
    Task task = Task.Run(() =>
    {
        Thread.Sleep(8000);
        RadNotification2.Text = "Execução Concluída!";
        RadNotification2.Show();
    });
    task.Wait();
}
 
protected void btnInserir_Click(object sender, EventArgs e)
{
    C001 c = new C001();
    int i = c.RegistrarDados(txtDescricao.Text);
 
    if (i != 0)
    {
        lblResultado.Text = "Registro Inserido!";
    }
    else
    {
        lblResultado.Text = "Registro nao pode ser Inserido!";
    }
    updForm.Update();
}

In this actual scenario, if i click on the second button while the request of first button still running, apparently, the first request is canceled, because the msg of my radNotificaion will never appears.

2 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 06 Apr 2012, 11:24 AM
Hi Bruno,

As you noted at the end of your post - the second request cancels the first while it is ongoing. This is just the way AJAX works. You can use the RadAjax controls instead, as they provide a mechanism for queuing AJAX requests as explained in this help article: http://www.telerik.com/help/aspnet-ajax/ajax-request-queuesize.html


Regards,
Marin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Bruno
Top achievements
Rank 1
answered on 09 Apr 2012, 03:48 PM
Unhappy, this possible solution doesnt work for my case, but im found one way to solve that using WCF + JavaScript, until now looks like the best way, if you have any other solution to solve can you pelase provide me? thankz
Tags
General Discussions
Asked by
Bruno
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Bruno
Top achievements
Rank 1
Share this question
or