# Main thread and thread

**URL:** <https://forums.unrealengine.com/t/main-thread-and-thread/51765>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [January 7, 2016, 4:04pm UTC](https://forums.unrealengine.com/t/main-thread-and-thread/51765 "2016-01-07T16:04:59Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![manoelneto](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@manoelneto](https://forums.unrealengine.com/u/manoelneto)\
**Post date:** [January 7, 2016, 7:03pm UTC](https://forums.unrealengine.com/t/main-thread-and-thread/51765/2 "2016-01-07T19:03:39Z")

</div>

You cannot interact with game objects from any thread other than the main game thread. To do so, you need to queue a task to be executed in the game thread like this:

```auto

FGraphEventRef Task= FFunctionGraphTask::CreateAndDispatchWhenReady(&]()
{
	// Code placed here will run in the game thread
}, TStatId(), NULL, ENamedThreads::GameThread);

// If you want to wait for the code above to complete do this:
FTaskGraphInterface::Get().WaitUntilTaskCompletes(Task);

```

---

_[View the full topic](https://forums.unrealengine.com/t/main-thread-and-thread/51765)._
