I created my own blueprint node that inherits from UBlueprintAsyncActionBase. The idea is to run some heavier UI related tasks in the background. It’s not really tied to anything in the world or gameplay so my activate
function looks like this.
void UMyAsyncNode::Activate()
{
AsyncTask(ENamedThreads::AnyBackgroundHiPriTask, [this]()
{
FString result = doStuff();
AsyncTask(ENamedThreads::GameThread, [this, result]()
{
OnResponse.Broadcast(result); // announce that we are done
});
}
this->RemoveFromRoot();
});
}
}
This works fine, but I would like to make sure that only one of these is running at one time? Is there a built in way for me to make sure I only activate one of these nodes at the time or do I have to control that myself?
This is my first venture into the Async nodes world so if I messed something up or could have done it easier for myself, let me know. Most examples I saw were using World->GetTimerManager().SetTimer(...)
but I didn’t really see the point of that.