Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

What are the disadvantages of async method?

Discussion in 'Scripting' started by Deleted User, Oct 19, 2018.

  1. Deleted User

    Deleted User

    Guest

    Why someone shouldn't use an async method instead of a coroutine?
     
  2. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,514
    That's a fairly broad conversation.

    Any context in which you're looking to discuss? How much do you know about async and coroutines? Have you read any articles on the topics to gather opinions out there?
     
  3. Deleted User

    Deleted User

    Guest

    Someone might use coroutines (mainly) to perform these tasks:
    1- Do something across multiple frames
    2- Do something with delays

    async methods can achieve the same thing.
    Specifically there is an open-source library that gives you ability to wait for fixed updates and other Unity events:
    http://www.stevevermeulen.com/index.php/2017/09/using-async-await-in-unity3d-2017/
    https://github.com/svermeulen/Unity3dAsyncAwaitUtil

    Other than that, you can return value from an async method (which you cannot do when using coroutines).

    I'm wondering is there anything that coroutines do that an async method does it worse (or can't do at all)?