Returning values from another thread

Basically I am trying to make a function that takes parameters on another thread because it is relatively expensive, then return an output value to the game thread I found Rama’s wiki thread very helpful (A new, community-hosted Unreal Engine Wiki - Announcements - Epic Developer Community Forums) but it did not cover how to get the values calculated back to the game thread.

How would I go about this?

Anybody? I really need help on this!

If you look at this section of my tutorial

The TArray is actually stored in the pc class, just avoid accessing it in the game thread until the other thread has finished filling it!

and never use ranged for loops when doing fancy stuff like this, use the standard for loop, so you check the length each time :slight_smile:


Sorry silly question, but I am new to all this. Because the thread variable is private, I can’t use the Thread->EnsureCompletion() (or whatever it is) to make sure that the thread has finished In the PC class. How should I go about knowing weather or not the thread is done?

How did you get it working? Can I see your code?