runAsync

A function that returns a Future object, which is an eventual result of an asynchronous operation

runAsync(function() {}) → returns any

Argument Reference

callback function

Closure function that returns a result to be resolved.

timeout numeric
Default: 1000

Timeout for the asynchronous process in milliseconds

Links more information about runAsync

Examples
Sample code invoking the runAsync function

future = runAsync(function(){
	return "Hello World!";
});
writeOutput(future.get());

Expected Result: Hello World!

future = runAsync(function(){
	return 5;
}).then(function(input){
	return input + 2;
});
result = future.get(3); // 3 is timeout(in ms)
writeOutput(result);

Expected Result: 5

future = runAsync(function(){
	return 5;
}).then(function(input){
	return input + 2;
}).error(function(){
	return "Error occurred.";
});
writeOutput(future.get());

Expected Result: 7

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub