How to Create Callback from another Thread?

What I’m trying to accomplish:
From my main game thread, I create handle and execute an FRunnable class that performs a task on another thread.
Once that thread has completed, I’d like some form of trigger to fire off a function in my main game thread again (the same class that launched the task in the first place).

What I’ve attempted:
I’ve tried to accomplish this with Delegates in various ways, but experience a failure at every turn.
At first, I attempted to use DECLARE_DYNAMIC_MULTICAST_DELEGATE, as described Here

DECLARE_DYNAMIC_MULTICAST_DELEGATE(FMyDeleteTest);

Except, I cannot compile and the Intellisence puts a red line under my declaration stating “this declaration has no storage class or type identifier”

so I tried with normal delegates. These compile file, but the desired function fails to fire…
I declared my delegate outside of the UClass
I assigned a variable of that type in both my threaded class, and the class doing the call and handling the completion.
I had the threaded class execute MyDelete.ExecuteIfBound() once it’s work was finished.
Before I call the mutlthread class, I Bind my delegate using BindUObject.

and yet, my function fails to call.

Should I be using TaskGraph instead because of the Multi-Thread approach?
Why can I not even declare a simple MultiCast delegate?

Any thoughts?

I’m going to amend this post via comment instead of editing (in case anyone else runs across the same issue).

First major problem, the mutlicast declaration error…
What I’ve found, is that you can only pull this off in header files that have the “generated.h” include for them. Basically, even though the declaration is not inside of the UClass block, the file you want to declare within must have a UClass section for these macros to work. I moved the mutlicast declaration in to another related header for a UClass object and it compiled just fine.

I was having this issue, because I was trying to make the declaration in the header file for my FRunnable child class. FRunnable is not a UObject Class, and as such, you cannot make a UClass child from this. My FRunnable class works just fine, but I cannot dip in to some of the many powerful benefits from UE macros as a side effect.

I still don’t have a solution for my thread callback as of yet.

I gave up on the delegate route, this just doesn’t look to be possible in this scenario.

Instead, I just created a timer to check on the thread state every few seconds. If the thread is finished, I resume any follow-up game thread code necessary, shutdown the thread and clear the timer.

You can also try to use Unreal Messaging system to communicate between threads.

The answer is really easier…
Wrap FRunable inside UObject pass to it the reference to the UObject(parent)
when FRunable ends call a parent function by reference, inside the UObject’s function you can fire the delegate.