I would like to have task that run asynchronously. I am using FNonAbandonableTask. I have made derived class from FNonAbandonableTask, implemented DoWork() function and also would like to know, when my DoWork function has finished their work. I have declared DECLARE_DELEGATE like this:

class FSaveGameTask : public FNonAbandonableTask
    FSaveGameTask(FMessageSaveGameTaskComplete OnTaskComplete);
    void DoWork();
    FMessageSaveGameTaskComplete    _OnTaskCompleteDelegate;

FSaveGameTask::FSaveGameTask(FMessageSaveGameTaskComplete OnTaskComplete)
    _OnTaskCompleteDelegate = OnTaskComplete;

void FSaveGameTask::DoWork()
   ...//some work

In another class derived from UUserWidget (UInGameUIContainerWidget) I implemented function OnTaskComplete and try to give this function as parameter to my task (when task finished - call OnTaskComplete).



    void OnSaveGameComplete();

In other function create and run my task:

(new FAutoDeleteAsyncTask<FSaveGameTask>(FMessageSaveGameTaskComplete::CreateUObject(this, &UInGameUIContainerWidget::OnSaveGameComplete)))->StartBackgroundTask();

But with no luck. I have received the folowing compiler error:
\UE_4.20\Engine\Source\Runtime\Core\Public\Delegates/DelegateSignatureImpl.inl(197): error C2039: ‘AsShared’: is not a member of ‘UInGameUIContainerWidget’

where UInGameUIContainerWidget is a class derived from UUserWidget.
What I have missed? Please help me with it
Maybe someone know another way how to determine when async task finished his work?

You are missing, or just not showing GetStatId(), don’t know if that will resolve the error but it is required:
Otherwise it looks fine.…eading-in-ue4/

FORCEINLINE TStatId GetStatId() const


RETURN_QUICK_DECLARE_CYCLE_STAT(PrimeCalculationAsyncTask, STATGROUP_ThreadPoolAsyncTasks);


Thank for you help. I already did it. I found that I had another use of the function


(stupid mistake) and that caused the problem. Everthing is fine now )))