Run Delegate on GameThread

is it possible to run a Delegate on the GameThread? I use a Delegate to set StaticMeshes inside a Chunk. But it crashes the Editor with “Assertion failed: IsInGameThread()”

It’s the opposite “Assertion failed: IsInGameThread()” means that IsInGameThread() returned false so it got run outside game thread

ok, but how can i run it on gamethread?

I found a Solution:

  FGraphEventRef Task = FFunctionGraphTask::CreateAndDispatchWhenReady([&]()
          //Put Stuff for GameThread here
  }, TStatId(), NULL, ENamedThreads::GameThread);

Hi @HOUmmel, thanks for positing an answer. I’m not really familiar with the syntax of whats going on with your answer though. It looks like a delegate handle, I think. But If you can, I’d appreciate it if you could explain it a little more. Do I just surround my existing delegate call with your answer or do I have to call something like Task.Execute()?.

Yeah I got it. I didn’t need the Event Ref, just used the CreateAndDispatchWhenReady function. I think you only need a FGraphEventRef handle if you want to see when the code triggers. But anyways, thanks for the solution.