Whatever message this page gives is out now! Go check it out!

whenComplete (Future method)

Last update:
May 18, 2026
Runs a callback on the completing thread when this Future finishes, success or failure. Does not convert a failed Future into a success.

Description

Synchronous counterpart to whenCompleteAsync. See that topic for behavior notes and the (value, error) callback shape.

Returns

A new Future.

Category

Asynchronous programming

Function syntax

future.whenComplete(action)

Parameters

ParameterDescription
actionRequired. A function (value, error).

See also

Example

Same pattern as the async variant; runs on the completing thread.

<cfscript>
    future = runAsync(function() { return 10; }).thenApplyAsync(function(x) { return x * 2; })    .whenComplete(function(value, error) {        
        variables.completed = true;        
        variables.finalValue = value;    });
        future.get();writeOutput(variables.completed & ":" & variables.finalValue); // true:20
</cfscript>
      

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page