Awaitable -- Main Thread vs Background Tread Question

If I would like to run an async operation off the main unity thread because it has no Unity dependency (e.g. a pure network request, should I

  • Modify my await operation to run on the background thread via synchronization context OR
  • Continue using Tasks OR
  • Do something else?

Thank you!

async void YourMethod()
{
    await Awaitable.BackgroundThreadAsync();

    // Your background job
    // ...

    await Awaitable.MainThreadAsync();

    // Your mainthread job
    // ...
}
3 Likes

Thanks, @Kichang-Kim !