<cftimeout>

Whilst similar to a <cfthread>, code run inside the <cftimeout> executes within the same scope as the current page

This tag may have a body.

This tag is also supported within <cfscript>

Introduced: 6.0.0.192

<cftimeout timespan=object ontimeout=any onerror=any forcestop=boolean ><!--- body --->[</cftimeout>]
Attribute Description
timespan
object, optional

Specifies the maximum amount of time, in seconds, to wait for code inside this tag to execute.

ontimeout
any, optional

A closure function (UDF) with the following signature:

function( timespan ) { }

onerror
any, optional

A closure function (UDF) with the following signature:

function( error ) { }

forcestop
boolean, optional

Force the thread to stop once the execution exceeds the allowed timespan

Examples

// timeout after 2sec
cftimeout( timespan=createTimeSpan(0, 0, 0, 2)){
	cfloop(times = "10"){
		cftimer(label = "Nap time" type = "outline") {
			echo("This case take run based upon time.");
			cfflush();
			sleep(400);
		}
	}
};

See also