4 ms·
So why don't you just define a non async method (A) and then one that is async (B) that calls A? If you want to run async then call B if not then call A. If yo
by sequence7 13y ago
So why don't you just define a non async method (A) and then one that is async (B) that calls A? If you want to run async then call B if not then call A.
If you could define a method as async and then call it either syncronously or not the whole point of the async keyword is lost. You would end up with the compiler doing a load of work because every developer will just slap async on every method just in case rather than actually thinking about what needs to be async and what doesn't.
Adding the async keyword is not a magic bullet, there's a huge amount of work going on under the hood every time you use it and it's important that developers appreciate that.
- earlz 13y agoThe problem with your two-method suggestion is that it's usually not /me/ I'm concerned about. The problem is usually things like "I need to open this file from a synchronous context in a Windows Store App". The problem is that with Windows Store (where async is suppose to shine), async is the rule, not the exception Also, two methods sharing the same code sounds absolutely horrible.
- sequence7 13y agoMethod B calls A it doesn't share any code and it is then explicit that one method is async and the other is not. You want to do two different things so why not have two methods?