Declare the async task as a member of the owner type.

Unreal editor v. 5.0.3
I m trying to repeat an asynchronous task like in the example: Multithreading
If I use creating task in BeginPlay:
void AMyAsyncActor::BeginPlay()
{
Super::BeginPlay();

FAsyncTask<FMyTask>* newTask = new FAsyncTask<FMyTask>();
newTask->StartBackgroundTask();

}

it works.

If i try to declare the task as a member of the owner type:
public:
// Sets default values for this actor’s properties
AMyAsyncActor();
FAsyncTask* newTask;

in *.h file i have error:
Error C2065 ‘FMyTask’: undeclared identifier;
Error C2955 ‘FAsyncTask’: use of class template requires template argument list

How to properly declare a new task?

is FMyTask declared in the same file? If not you need to include it in the cpp and forward declare it in the header.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.