How To Pause In .NET?

J

Joe Delphi

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
 
M

Mark Rae

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...
 
J

John Timney \( MVP \)

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
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

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);">
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top