TGViewer
Everyday Unity Everyday Unity @everydayunity · 1.18K subscribers
Post #2592 1.3K
Why await Resumes on the Main Thread in Unity - SynchronizationContext

I have been working on projects that extensively use async, both Task and UniTask, for many many years already. And we always had a lot of strong engineers who understood the ins and outs of how it works in Unity. So I had a great opportunity to learn from them not only how it works, but, more importantly, how to use it correctly to avoid critical issues.

I have also conducted many dozens of interviews, and I noticed that a lot of people just use async and do not know the internals or about the existence of a custom synchronization context in Unity. And that is usually okay for 99% of cases, you are here to make games in the end. However, when this remaining 1% happens in a critical module, it may cause unpredictable harm, like players losing progress or an ANR rate three times higher than usual.

I also see a lot of confusion around asyncs in general. For example, some people assume that using await in Unity means creating new threads and doing multithreading, without realizing that it would be very inefficient to use multithreading for something like UniTask.Delay. It’s also easy to overlook the difference between creating threads and using the thread pool, or that an async method can execute synchronously. Sometimes people don’t fully grasp the purpose of ValueTask or what happens if the same UniTask is awaited twice. And I am not even talking about the magic that compiler does for us when we write "await" and the difference in how the async state machine is compiled in debug and release builds.

I also noticed that people who are willing to dive into how things work under the hood, and who show engineering curiosity, can troubleshoot issues much better. They don’t stop after the first unsuccessful step when we have tricky bugs to uncover.

So you don’t need to know what this post talks about to make games, but it will help you in the future not only pass heavy theory interviews (which is a widespread thing), but also prevent critical issues, which is extremely important when you work on a live game with millions of users.

https://discussions.unity.com/t/why-await-resumes-on-the-main-thread-in-unity-synchronizationcontext/1700147

#async #synchronizationcontext
  • 🔥 11
  • 👍 7
More from @everydayunity
  1. Sep 22, 2026Introducing GPT‑6 Sol and Luna And better & cheaper sol and luna as an immediate response…
  2. Sep 22, 2026Introducing Claude Opus 5.5 \ Anthropic Cost and speed. Opus 5.5 requires less compute to…
  3. Sep 21, 2026Claude Code effort level and model selection effort means more than just "thinking time."…
  4. Sep 19, 2026Netcode for GameObjects 3.0.0 is now available It is preparation for Unity’s shared Netcod…
  5. Sep 9, 2026Unity Plugin Official Unity plugin for Claude. https://claude.com/plugins/unity #ai
  6. Sep 5, 2026Have you tested Astra already? I checked deepswe bench and decided to test it with medium…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →