Asynchrone

3 posts, 0 answers
  1. Bruno
    Bruno avatar
    20 posts
    Member since:
    Feb 2012

    Posted 05 Apr 2012 Link to this post

    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. Marin Bratanov
    Admin
    Marin Bratanov avatar
    4713 posts

    Posted 06 Apr 2012 Link to this post

    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.
  3. Bruno
    Bruno avatar
    20 posts
    Member since:
    Feb 2012

    Posted 09 Apr 2012 Link to this post

    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
Back to Top