Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Strange problem with System.Threading.Thread.Sleep...

Strange problem with System.Threading.Thread.Sleep...

Scheduled Pinned Locked Moved ASP.NET
helpquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    Infernojericho
    wrote on last edited by
    #1

    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

    G I 2 Replies Last reply
    0
    • I Infernojericho

      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

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      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; }

      1 Reply Last reply
      0
      • I Infernojericho

        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 Offline
        I Offline
        Ista
        wrote on last edited by
        #3

        Yeahn and your just telling the server to wait 10 seconds before processing the page. Like guffa said use setTimout from the onload() event in the body 1 line of code equals many bugs. So don't write any!!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups