– Common Function Library Project


Last updated April 11, 2008


Nolan Erck

Version: 1 | Requires: CF6 | Library: UtilityLib

This is a variation of the sleep() UDF already on However, fake_sleep() is a bit more "web hosting friendly". If your web host has CreateObject( "java" ) turned off (as mine did), the existing sleep() method will not work. This UDF is a "side step" around that issue. (I've noted it above as "requires MX", however I think CF 5 support is possible as well with a minor edit or 2.)

Return Values:
Returns nothing.


<cfset fakesleep( 3000 ) />


Name Description Required
timeToSleep Number of miliseconds to sleep. Yes

Full UDF Source:

 Causes the current page request to &quot;sleep&quot; for the given duration, before continuing.
 @param timeToSleep 	 Number of miliseconds to sleep. (Required)
 @return Returns nothing. 
 @author Nolan Erck ( 
 @version 1, April 11, 2008 
<cffunction name="fakesleep" access="public" returntype="void" output="false">
	<cfargument name="timeToSleep" type="numeric" required="true" hint="the number of miliseconds you wish to sleep for." />

	<cfset var bContinue 	= false />	
	<cfset var startTime 	= getTickCount() />
	<cfset var endTime 		= 0 />
	<cfset var elapsedTime  = 0 />

	<cfloop condition="NOT bContinue">
		<cfset endTime 		= getTickCount() />
		<cfset elapsedTime  = endTime - startTime />
		<cfif elapsedTime gte arguments.timeToSleep>
			<cfset bContinue = true />
blog comments powered by Disqus


Latest Additions

Kevin Cotton added
May 5, 2016

Raymond Camden added
April 25, 2016

Chris Wigginton added
January 18, 2016

Gary Stanton added
November 19, 2015

Sebastiaan Naafs - van Dijk added
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson