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

runAfterEither

Last update:
May 18, 2026
When either this Future or another Future completes successfully first, runs a parameterless action on the completing thread.

Description

runAfterEither is an instance method on a CFML Future. You pass a second Future to race. When either stage completes successfully first, your action runs on the completing thread. The action takes no arguments. Use it for cleanup or notifications that do not need the winning value. A new Future is returned for chaining.
This is the synchronous counterpart to runAfterEitherAsync.

Returns

A new Future.

Category

Asynchronous programming

Function syntax

future.runAfterEither(other, action)

Parameters

ParameterDescription
otherRequired. The other Future to race.
actionRequired. A function with no parameters that performs work (void semantics).

Example

Run a flag after the first of two tasks completes successfully.

<cfscript>
    f1 = runAsync(function() { return 1; });
    f2 = runAsync(function() {
        sleep(1000);
        return 2;
    });
    after = f1.runAfterEither(f2, function() {
        variables.ran = "YES";
    });
    after.get();
    writeOutput(variables.ran); // YES
</cfscript> 
      

See also

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