<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
|
edit
Specifies the maximum amount of time, in seconds, to wait for code inside this tag to execute. |
onTimeout
any, optional
|
edit
A closure function (UDF) with the following signature:
|
onError
any, optional
|
edit
A closure function (UDF) with the following signature:
|
forcestop
boolean, optional
|
edit
Force the thread to stop once the execution exceeds the allowed timespan |
Examples
edit// 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
- Threads
- Request Timeout
- <cfthread>
- Timeout
- Search Issue Tracker open_in_new
- Search Lucee Test Cases open_in_new (good for further, detailed examples)