473,725 Members | 2,264 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@_myrealb ox_no_spam.com
Jul 16 '05 #1
2 5310
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="javas cript">
window.setTimeo ut('window.hist ory.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************ *********@netsc ape.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="javas cript">
window.setTime out('window.his tory.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@_myrealb ox_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
18745
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 nanosleep(), depending on platform }
1
1554
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 asynchronous programming and multithreaded programming two different pictures? As I read the help topic above it is not clear to me if the design pattern opens a new thread or not to run the methods asynchronously. 2) One unique thread can run...
6
1435
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
3530
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> ./sleeper sleeping for 5 seconds unslept amount is 2 (User hits Ctrl-C after 3 seconds) unix>
8
4223
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 other events. I am looking for somedata on how to use Waitable Timer APIs with VB.NET Thanks in Advance.
0
1755
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 ------------------------------------------------------------------------------------------------------------------------- My web.config file: ---------------------
7
2582
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 Threading.Thread(AddressOf StartProcess) t.IsBackground = True t.Priority = ThreadPriority.Highest t.Start()
4
11070
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." My questions: 1. By "other threads" - does the above statement refer specifically and only to other threads in the current AppDomain?
2
1820
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 thread ABC needs to get thread XYZ's quick attention. My first attempt at this was to have thread ABC merely set a global flag variable that thread XYZ would check at specific points in its execution, and if it saw that the flag was set it would take...
0
8889
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8752
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9401
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9257
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9116
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8099
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4519
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3228
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2157
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.