Skip to main content

Timeline for Why do we need the async keyword?

Current License: CC BY-SA 3.0

6 events
when toggle format what by license comment
Feb 18, 2013 at 23:58 comment added Aaronaught @Justin984: Not every method returning Task<T> actually has the characteristics of an async method - for example, you might just run through some business/factory logic and then delegate to some other method returning Task<T>. async methods have a return type of Task<T> in the signature but don't actually return a Task<T>, they just return a T. In order to figure all of this out without the async keyword, the C# compiler would have to do all sorts of deep inspection of the method, which would probably slow it down quite a bit, and lead to all manner of ambiguities.
Feb 18, 2013 at 21:45 comment added ratchet freak it helps when you want to schedule multiple asyncs at the same time so they don't run one after another but concurrently (if threads are available at least)
Feb 18, 2013 at 21:39 comment added ConditionRacer I guess I'm curious why the compiler needs it. Couldn't it just parse the method and see that await is somewhere in the method body?
Feb 18, 2013 at 21:37 comment added ratchet freak @Justin984 it definitely helps to signal to the compiler something special needs to happen
Feb 18, 2013 at 21:34 comment added ConditionRacer So this is really something for the reader/programmer, and not so much for the compiler?
Feb 18, 2013 at 21:33 history answered ratchet freak CC BY-SA 3.0