简体   繁体   中英

Set timer in asp.net page

How can I set a timer on my asp.net page so that it will pause/wait for few seconds (say 5 seconds) then do rest of stuff in the code?

Thanks.

If you want to pause execution on the server for some reason, you could simply invoke the Sleep method on the current thread, like so...

System.Threading.Thread.Sleep(5000);

If you want to pause execution in the browser, you could try the trick documented here .

Unfortunately, as a commenter mentioned, that javascript trick will block the browser process. Firefox offers an alternative that doesn't block execution documented here , but unfortunately that's only Firefox.

您可以执行Thread.Sleep(millisecondsToWait)但这可能会导致不良的用户体验。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM