I was just doing some async work with this and noticed continuations seem to be working, though I have no idea when they were added. Potentially years ago. I could not find any documentation or usage examples anywhere.
But something like this worked for me:
TFuture<void> SlowTaskAsync()
{
return Async(EAsyncExecution::TaskGraph,[]()
{
ExecuteSlowTask();
}).Then([](auto Future)
{
DoSomethingElseAfterward();
});
}
The continuation takes the previous (completed) future as a parameter and creates its own future from the Then() call. (If the continuation code returned an int32 in the above code, you could have the outer SlowTaskAsync function return a TFuture, even though the main task body itself creates a TFuture in this case)
However, it’s important to know that the continuation also runs on the same thread as the original task (I think). If you wanted to continue on the main thread, you could await another async call back to the main thread within the continuation, but then you’d have to be careful that any code calling SlowTaskAsync in this exmaple doesn’t await it from the main thread otherwise it’ll cause a deadlock. Not sure if there’s a way around this.