I have a page that performs a long-term task (10 to 15 seconds) in the page_load method.
I have a client-side javascript code that displays the user an “animated gif page” for the user.
I can call the JavaScript method from the code to display the animated gif page, however, the long-term task hangs in the user interface so that the animated gif does not actually appear until after the completion of the long-term task, which is the exact opposite of what I want.
To test this, in my page_load method, I make a JavaScript method call to display an animated gif. Then I use Thread.Sleep (10000). What happens is that the animated gif is only shown after Thread.Sleep is complete.
Obviously I'm doing something wrong.
Any advice would be appreciated.
Thank.
Chris
The following is sample code:
protected void Page_Load(object sender, EventArgs e)
{
ClientScript.RegisterStartupScript
(GetType(), "Javascript", "javascript: ShowWaitIndicator(); ", true);
Response.Flush();
Thread.Sleep(10000);
}
Chris source
share