Strange problem with System.Threading.Thread.Sleep...
-
I am trying to create a scenerio where a user clicks on page A, it will be redirected to page B, wait for 10 seconds, and then automatically redirect itself to C. In Page A, I created a Button Control, with the command Response.Redirect ("B.aspx") and in Page B, I used System.Threading.Thread.Sleep (10000); Response.Redirect("C.aspx"); (it is placed under Page_Load) well, it does sleep for 10 seconds, but the strange thing is that it never displays the contents of page B at all. After redirecting from A, it waits for 10 seconds then jumps directly to Page C I don't understand, what should I do to get it to show Page B, then wait for 10 seconds before redirecting to C.aspx??? Thanks
-
I am trying to create a scenerio where a user clicks on page A, it will be redirected to page B, wait for 10 seconds, and then automatically redirect itself to C. In Page A, I created a Button Control, with the command Response.Redirect ("B.aspx") and in Page B, I used System.Threading.Thread.Sleep (10000); Response.Redirect("C.aspx"); (it is placed under Page_Load) well, it does sleep for 10 seconds, but the strange thing is that it never displays the contents of page B at all. After redirecting from A, it waits for 10 seconds then jumps directly to Page C I don't understand, what should I do to get it to show Page B, then wait for 10 seconds before redirecting to C.aspx??? Thanks
That is because page B is never sent to the browser. You are making a redirect in page B, then you can't also return page contents. If you want a page to display for ten seconds, you have to use javascript. You can't do that with server side code. Use window.setTimeout to execute javascript with a delay. --- b { font-weight: normal; }
-
I am trying to create a scenerio where a user clicks on page A, it will be redirected to page B, wait for 10 seconds, and then automatically redirect itself to C. In Page A, I created a Button Control, with the command Response.Redirect ("B.aspx") and in Page B, I used System.Threading.Thread.Sleep (10000); Response.Redirect("C.aspx"); (it is placed under Page_Load) well, it does sleep for 10 seconds, but the strange thing is that it never displays the contents of page B at all. After redirecting from A, it waits for 10 seconds then jumps directly to Page C I don't understand, what should I do to get it to show Page B, then wait for 10 seconds before redirecting to C.aspx??? Thanks