Server.Transfer doesn't work in a timer callback

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jim Hammond

    #1

    Server.Transfer doesn't work in a timer callback

    The code below works except that calling Server.Transfer generates the
    following exception, and I don't know why yet:

    "Error executing child request for Form_Welcome.as px."

    Although a page has a short lifespan, I have discovered that the timer
    callback is in fact being called after 10 seconds.

    Notet hat "p" appears to be perfectly valid and returns equal when compared
    to the original Web Form object, which I saved using Application.Add
    specifically to test for such equality.


    private void Page_Load(objec t sender, System.EventArg s e)
    {
    // Set timer to call Page_PostLoad in 10 seconds
    timerDelegate = new TimerCallback(P age_PostLoad);
    timer = new Timer( timerDelegate, this, 10000, 0 );
    }

    static void Page_PostLoad(O bject page)
    {
    Form_ProceedToD esk p = (Form_ProceedTo Desk)page;
    try
    {
    // stop timer
    p.timer.Dispose ();
    p.timer = null;
    p.GoHome();
    }
    catch(Exception ex)
    {
    p.ExceptionDisp lay( ex );
    }
    }

    public void GoHome( )
    {
    Server.Transfer ("Form_Welcome. aspx");
    }



Working...