Making ColdFusion Sleep
Often times you want the server to pause execution of a page, or go to sleep for a short while. You may be waiting for a file to be written to the file system etc.
You can do achieve this in the following fashion:
The example above makes the server call “sleep” for 5 seconds.
Ryan Duckworth states:
“A java thread (which ColdFusion code is converted to) is doing a NOP (no operation) procedure during a java Sleep command which causes no inefficiency. The multi-processing nature of the CPU handles this functionality for you and will use those CPU cycles with other requests during the sleep.”
Note that I usually have this in a Utility component with lots of functions I can call when needed. For example:
1 2 3 4 5 6 7 8
So then I can call application.utility.sleep(1000);