[CLOSED] Timeout - Transaction abortedafter 30 seconds

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Timeout - Transaction abortedafter 30 seconds

    I tried to summarize my scenario

    The method UpdateTimeStamp takes a long time to complete

    Even if you set the timeout after 30 seconds the page times out

    I discovered that the problem is not the Button1 the taskmanager but it crashes when running UpdateTimeStamp.

    I also tried to stop my taskmanager

    the question remains

    This example works only if the session is empty


    it's clear my problem?


    This is the code:

    <%@ Page Language="C#" %>
    <%@ Import Namespace="System.Threading" %>
    <%@ Import Namespace="System.Collections.Generic" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">    
        protected void Page_Load(object sender, EventArgs e)
        {
            Session["ok"] = "ppp";
        }    
        protected void UpdateTimeStamp(object sender, DirectEventArgs e)
        {
            TaskManager1.StopAll();              
            System.Threading.Thread.Sleep(80000);      
            X.Msg.Notify("The Server Time is: ", DateTime.Now.ToLongTimeString()).Show();
        }
    
       
    
        protected void RefreshTime(object sender, DirectEventArgs e)
        {
            ServerTimeLabel.Text = DateTime.Now.ToString("HH:mm:ss") + Session.SessionID; ;
        }
        
    </script>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>DirectEvents Summary - Ext.NET Examples</title>
        <link href="../../../../resources/css/examples.css" rel="stylesheet" type="text/css" /></head>    
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server"></ext:ResourceManager>
            <ext:Button ID="Button1" runat="server" Text="Click Me">
                <DirectEvents>
                    <Click OnEvent="UpdateTimeStamp" Timeout="100000">
                       <EventMask ShowMask="true" />
                    </Click>
                </DirectEvents>
            </ext:Button>         
             <ext:Label ID="ServerTimeLabel" runat="server" />    <br />         
              <ext:TaskManager ID="TaskManager1" runat="server">
                
                  <Tasks>
                    <ext:Task Interval="1000">          
                         <DirectEvents>
                            <Update OnEvent="RefreshTime"/>
                        </DirectEvents>          
                    </ext:Task>       
                </Tasks>
            </ext:TaskManager>             
        </form>
    </body>
    </html>
  2. #2
    Hi,

    The following thing happens there.

    1. RefreshTime DirectEvent request is initiated every second.
    2. Click on Button
    3. UpdateTimeStamp is executed and it causes sleeping of current thread.
    4. RefreshTime DirectEvent request is STILL initiated every second.
    5. But RefreshTime waits till thread is sleeping. It waits more then 30 seconds (you know, default timeout)
    6. Thus, exception "transaction aborted" is thrown by RefreshTime

    I would suggest you to to stop a task in Before handler of UpdateTimeStamp DirectEvent and launch this task again in Success handler.

    Sure, you could set respective Timeout for RefreshTime but I would NOT suggest you this way.
  3. #3
    ???

    <%@ Page Language="C#" %>
    <%@ Import Namespace="System.Threading" %>
    <%@ Import Namespace="System.Collections.Generic" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        
        protected void Page_Load(object sender, EventArgs e)
        {
            Session["ok"] = "ppp";
        }
        
        protected void UpdateTimeStamp(object sender, DirectEventArgs e)
        {
            TaskManager1.StopAll(); 
        }
        
         protected void RunLongManager(object sender, DirectEventArgs e)
         {
             System.Threading.Thread.Sleep(80000);
             X.Msg.Notify("The Server Time is: ", DateTime.Now.ToLongTimeString()).Show();
         }
          
    
       
    
        protected void RefreshTime(object sender, DirectEventArgs e)
        {
            ServerTimeLabel.Text = DateTime.Now.ToString("HH:mm:ss") + Session.SessionID; ;
        }
        
    </script>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>DirectEvents Summary - Ext.NET Examples</title>
        <link href="../../../../resources/css/examples.css" rel="stylesheet" type="text/css" /></head>
         
        
        
        
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server"></ext:ResourceManager>
            <ext:Button ID="Button1" runat="server" Text="Click Me">
                <DirectEvents>
                    <Click OnEvent="UpdateTimeStamp" Success="RunLongManager" Timeout="100000">
                       <EventMask ShowMask="true" />
                    </Click>
                </DirectEvents>
            </ext:Button> 
            
             <ext:Label ID="ServerTimeLabel" runat="server" />    <br />     
            
            
              <ext:TaskManager ID="TaskManager1" runat="server">
                
                  <Tasks>
                    <ext:Task Interval="1000">          
                         <DirectEvents>
                            <Update OnEvent="RefreshTime"/>
                        </DirectEvents>          
                    </ext:Task>       
                </Tasks>
            </ext:TaskManager>  
            
            
          
                    
        </form>
    </body>
    </html>
  4. #4
    Hi,

    Please always run long-run task as async operation
    <%@ Page Language="C#" %>
    <%@ Import Namespace="System.Threading" %>
    <%@ Import Namespace="System.Collections.Generic" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
     
    <script runat="server">    
        protected void Page_Load(object sender, EventArgs e)
        {
            Session["ok"] = "ppp";
        }    
        
        protected void UpdateTimeStamp(object sender, DirectEventArgs e)
        {
            System.Threading.ThreadPool.QueueUserWorkItem(delegate(object state) {            
                System.Threading.Thread.Sleep(80000);
                Session["WorkIsFinished"] = true;
            });        
        }    
     
        protected void RefreshTime(object sender, DirectEventArgs e)
        {
            ServerTimeLabel.Text = DateTime.Now.ToString("HH:mm:ss") + Session.SessionID; ;
            var flag = Session["WorkIsFinished"];
            if (flag != null && (bool)flag)
            {
                TaskManager1.StopAll();
                X.Msg.Notify("The Server Time is: ", DateTime.Now.ToLongTimeString()).Show();
                Session["WorkIsFinished"] = false;
            }
        }
         
    </script>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>DirectEvents Summary - Ext.NET Examples</title>
        <link href="../../../../resources/css/examples.css" rel="stylesheet" type="text/css" /></head>    
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server"></ext:ResourceManager>
            <ext:Button ID="Button1" runat="server" Text="Click Me">
                <DirectEvents>
                    <Click OnEvent="UpdateTimeStamp">
                       <EventMask ShowMask="true" />
                    </Click>
                </DirectEvents>
            </ext:Button>         
             <ext:Label ID="ServerTimeLabel" runat="server" />    <br />         
              <ext:TaskManager ID="TaskManager1" runat="server">
                 
                  <Tasks>
                    <ext:Task Interval="1000">          
                         <DirectEvents>
                            <Update OnEvent="RefreshTime"/>
                        </DirectEvents>          
                    </ext:Task>       
                </Tasks>
            </ext:TaskManager>             
        </form>
    </body>
    </html>
    Please see the following sample
    https://examples1.ext.net/#/Miscella...r_Side_Update/

    http://msdn.microsoft.com/en-us/magazine/cc163577.aspx

    Also, I recommend to read about async pages in ASP.NET
  5. #5
    Unfortunately the code I've written is unusable

    System.Web.HttpContext.Current.Session is null

    I can not even change the syntax

    it is an application in three layers (Presentation, Bussinness, Data)

    I only have to develop the presentation layer
  6. #6
    Hi,

    In this case you have to deal with other developers about synchronization mechanism
  7. #7
    I think I'm close to the solution
    I must be sure that the long operation starts after the taskmanager is stopped
    Is there a method to tell me whether a task is running?
  8. #8
    Please use
    TaskManager1.getTask(<"TaskID" or task's index).executing
  9. #9
    I have no method getTask
    the list of methods is in the image attached
    for a task you can set a timeout very long?
    Attached Thumbnails Click image for larger version. 

Name:	1.jpg 
Views:	106 
Size:	22.7 KB 
ID:	2238  
  10. #10
    I have no method getTask
    the list of methods is in the image attached
    I posted JavaScript code, not code behind.

    Well, to determine it on server side you could use some Page property, for example, .Lock. Set it to true in one DirectEvent handler and check/reset in another.

    for a task you can set a timeout very long?
    You could set Delay for any DirectEvent.

    Example
    <Update OnEvent="RefreshTime" Delay="1000000" />
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 17
    Last Post: Dec 29, 2012, 6:25 AM
  2. TaskManager Timer CountUP with seconds
    By krishna in forum 1.x Help
    Replies: 0
    Last Post: Apr 30, 2012, 6:32 AM
  3. Replies: 6
    Last Post: Nov 15, 2011, 2:02 AM
  4. Auto update grid panel every x seconds.
    By Kamyar in forum 1.x Help
    Replies: 0
    Last Post: Feb 10, 2011, 6:31 AM
  5. Replies: 5
    Last Post: Aug 11, 2010, 7:53 PM

Tags for this Thread

Posting Permissions