Async
[UClass]
public partial class AAsyncActor : AActor
{
// Cancellation token is optional.
[UFunction(FunctionFlags.BlueprintCallable)]
public async Task<int> SlowAdd(int lhs, int rhs, CancellationToken cancellationToken)
{
PrintString($"Commencing the world's slowest addition...");
await Task.Delay(1000, cancellationToken).ConfigureWithUnrealContext();
if (cancellationToken.IsCancellationRequested || IsDestroyed) { return default; }
int result = lhs + rhs;
PrintString($"{lhs} + {rhs} = {result}!");
return result;
}
}
Last updated