473,503 Members | 1,797 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5267
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
18648
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
1539
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
1416
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
3515
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
4206
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
1743
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
2569
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
11052
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
1811
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...
0
7199
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7076
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7323
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6984
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7453
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5005
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3151
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
732
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
377
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.