Skip to content

Instantly share code, notes, and snippets.

@ivo-alves
ivo-alves / AsyncTaskMain.cpp
Created May 10, 2023 10:03
Unreal's built-in task graph system async task (runs on main thread)
// start Foreground worker
FGraphEventRef Task = FFunctionGraphTask::CreateAndDispatchWhenReady([this]() {
AsyncHadronTick();
}, TStatId(), nullptr, ENamedThreads::AnyThread);
void AVehicleTest::AsyncHadronTick()
{
double LastStepTime = FPlatformTime::Seconds();
// non static
FDelegateHandle handle = FWorldDelegates::OnCurrentLevelChanged.AddUObject(this, &Foo::OnLevelLoaded);
// static
FWorldDelegates::FWorldInitializationEvent::FDelegate Foo::OnPostWorldInitHandle = nullptr;
Foo::Bar()
{
if (!OnPostWorldInitHandle.IsBound())
{