472,805 Members | 1,756 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,805 software developers and data experts.

Sleep asynchronous?

JW
I wanted have this as part of a flood control script:
<?
echo ("Flood control in place - please wait " . $floodinterval . " seconds
between postings.");

sleep(5);
// go back two pages
echo "<script>window.history.go(-2);</script>";
exit;
?>

Problem is that the first echo never shows up on the page; it displays a blank
page (well, the page constructed up to PHP section), then sleeps for the five
seconds and goes back two pages.

Why?

Thanks -

jon

--
jwayne@_myrealbox_no_spam.com
Jul 16 '05 #1
2 5115
JW wrote:
I wanted have this as part of a flood control script:
<?
echo ("Flood control in place - please wait " . $floodinterval . " seconds
between postings.");

sleep(5);
// go back two pages
echo "<script>window.history.go(-2);</script>";
exit;
?>

Problem is that the first echo never shows up on the page; it displays a blank
page (well, the page constructed up to PHP section), then sleeps for the five
seconds and goes back two pages.

Why?


Could be caching is turned on with your web server. So you're spitting
out the notice, but the server is holding all your output until the
script is done. In which case the browser gets the <script> and
executes it right away, before you can see the notice posted on the page.

You could have the script execute with a

<script language="javascript">
window.setTimeout('window.history.go(-2);', 5000);
</script>

which will tell the browser to wait 5 seconds before going back. Even
if caching is turned on, this should work.

Jason

Jul 16 '05 #2
JW
Jason Dumler <du*********************@netscape.net> wrote:
JW wrote:
I wanted have this as part of a flood control script:
<?
echo ("Flood control in place - please wait " . $floodinterval . " seconds
between postings.");

sleep(5);
// go back two pages
echo "<script>window.history.go(-2);</script>";
exit;
?>

Problem is that the first echo never shows up on the page; it displays a blank
page (well, the page constructed up to PHP section), then sleeps for the five
seconds and goes back two pages.

Why?


Could be caching is turned on with your web server. So you're spitting
out the notice, but the server is holding all your output until the
script is done. In which case the browser gets the <script> and
executes it right away, before you can see the notice posted on the page.

You could have the script execute with a

<script language="javascript">
window.setTimeout('window.history.go(-2);', 5000);
</script>

which will tell the browser to wait 5 seconds before going back. Even
if caching is turned on, this should work.

Worked like a charm! Thanks much...

jon
--
jwayne@_myrealbox_no_spam.com
Jul 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Alo Sarv | last post by:
Hi From what I have understood from various posts in this newsgroup, writing event loops pretty much comes down to this: while (true) { handleEvents(); sleep(1); // or _sleep() or...
1
by: Julian Hershel | last post by:
Reading about asynchronous programming (ms-help://MS.NETFrameworkSDK/cpguidenf/html/cpconasynchronousdesignpatterno verview.htm) I could not clarify some doubts. Hope you can help me. 1) Are...
6
by: Thomas | last post by:
hello, what is the better solution if it is possible to choose? a timer or sleep? which one is better for min resources? Thomas
10
by: syed | last post by:
I am trying to write a little program that goes to sleep for 5 seconds. However, if the user presses Ctrl-C, it interrupts the sleep and prints the unslept amount. For example: unix>...
8
by: Sam | last post by:
Hello everyone, Can anyone provide me some idea on how to replace the Sleep method. Major Disadvantage that I face with the Sleep method is that the application freezes and does not respond to any...
0
by: Bishoy George | last post by:
Hi, I have a asp.net 2.0 web application. I want to implement the asynchronous model through http handler in web.config ...
7
by: davidst95 | last post by:
Hello, I have a program that runs a long process. I tried to add a thread to check if the use hit a cancel button to abort the process. Dim t As Threading.Thread t = New...
4
by: Frankie | last post by:
This is from MSDN online (http://msdn2.microsoft.com/en-us/library/d00bd51t.aspx): "Specify zero (0) to indicate that this thread should be suspended to allow other waiting threads to execute." ...
2
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post by:
Hello, I have a thread ABC that starts another thread XYX. Thread XYZ monitors various things and if there is no work to do it calls Thread.Sleep to sleep for a minute or so. Occasionally...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.