How To Pause In .NET?

Discussion in 'ASP .Net' started by Joe Delphi, May 7, 2006.

  1. Joe Delphi

    Joe Delphi Guest

    Hi,

    Newbie question. I need to insert a 5 second delay into my code
    before re-directing the user to a different page.

    I need something like:

    Wait(5) or Pause(5) or Delay(5)

    Is there a command in .NET to handle this requirement ?

    Jim
     
    Joe Delphi, May 7, 2006
    #1
    1. Advertising

  2. Hi Joe,

    You're close, try

    Threading.Thread.Sleep(5000)

    http://msdn2.microsoft.com/en-us/library/system.threading.thread.sleep.aspx

    Ken
    Microsoft MVP [ASP.NET]


    "Joe Delphi" <> wrote in message
    news:k4b7g.18354$Qz.6617@fed1read11...
    > Hi,
    >
    > Newbie question. I need to insert a 5 second delay into my code
    > before re-directing the user to a different page.
    >
    > I need something like:
    >
    > Wait(5) or Pause(5) or Delay(5)
    >
    > Is there a command in .NET to handle this requirement ?
    >
    > Jim
    >
    >
     
    Ken Cox - Microsoft MVP, May 7, 2006
    #2
    1. Advertising

  3. Joe Delphi

    V Guest

    Thread.Sleep(5000).

    - Vaibhav
     
    V, May 7, 2006
    #3
  4. Joe Delphi

    Mark Rae Guest

    "Joe Delphi" <> wrote in message
    news:k4b7g.18354$Qz.6617@fed1read11...

    > Newbie question. I need to insert a 5 second delay into my code
    > before re-directing the user to a different page.


    Do you *really* need to do this...? Chances are that, unless you EXPLCITLY
    tell the user that they're being made to wait 5 seconds, they'll think
    something has gone wrong with your site and will start clicking buttons
    again, hitting the back and/or refresh button etc...
     
    Mark Rae, May 7, 2006
    #4
  5. Joe,

    your after

    Threading.Thread.Sleep(5000)

    However, this kind of thing is always better done client side if you can get
    away with it, releasing the server processing asap. You should consider
    using a javascript redirect or a client side meta refresh rather than
    hogging the worker thread for each user for five seconds on the server? On
    a busy site, that can cause a lot of paused threads and a lot of tied up
    resources.

    --
    Regards

    John Timney
    Microsoft MVP


    --
    Regards

    John Timney
    Microsoft MVP

    "Joe Delphi" <> wrote in message
    news:k4b7g.18354$Qz.6617@fed1read11...
    > Hi,
    >
    > Newbie question. I need to insert a 5 second delay into my code
    > before re-directing the user to a different page.
    >
    > I need something like:
    >
    > Wait(5) or Pause(5) or Delay(5)
    >
    > Is there a command in .NET to handle this requirement ?
    >
    > Jim
    >
    >
     
    John Timney \( MVP \), May 7, 2006
    #5
  6. No, that is not what you need to do. If you put a delay in your code it
    will only mean that it takes five more seconds to create the page. In
    the mean time the browser will just appear dead.

    What you want to do is to send a page to the client that will redirect
    after being displayed for five seconds.

    You can do that using Javascript:

    <body
    onload="window.setTimeout('window.location=\'someotherpage.html\';',5000);">

    Joe Delphi wrote:
    > Hi,
    >
    > Newbie question. I need to insert a 5 second delay into my code
    > before re-directing the user to a different page.
    >
    > I need something like:
    >
    > Wait(5) or Pause(5) or Delay(5)
    >
    > Is there a command in .NET to handle this requirement ?
    >
    > Jim
    >
    >
     
    =?ISO-8859-1?Q?G=F6ran_Andersson?=, May 7, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jason Shohet
    Replies:
    10
    Views:
    1,973
    Kevin Spencer
    Jun 18, 2004
  2. GrantMagic

    pause a loop

    GrantMagic, Jul 28, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    2,006
  3. Leah

    Pause a web page?

    Leah, Mar 15, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    3,227
    Steve C. Orr [MVP, MCSD]
    Mar 15, 2006
  4. Rick
    Replies:
    4
    Views:
    41,812
    Roedy Green
    Oct 8, 2003
  5. E Tepp

    Pause Util Value is returned

    E Tepp, Dec 15, 2003, in forum: Java
    Replies:
    2
    Views:
    445
    Matthew Zimmer
    Dec 15, 2003
Loading...

Share This Page