Make a static function in you .h file
static FGraphEventRef RunLambdaOnGameThread(TFunction< void()> InFunction);
In CPP
FGraphEventRef YouClassName::RunLambdaOnGameThread(TFunction< void()> InFunction)
{
return FFunctionGraphTask::CreateAndDispatchWhenReady(InFunction, TStatId(), nullptr, ENamedThreads::GameThread);
}
Now you can run a function on the game thread.
void YourClassName::YourFunc(params)
{
RunLambdaOnGameThread([capture any vars by ref or by value] {
// Your func Implementation
});
}
Hope this helps.