Re:Everything .NET programmers know about Asynchronous Progr...
by earlz on Monday September 16, 2013 @02:13PM
(#6394772)
The 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.
Re:Everything .NET programmers know about Asynchronous Progr...
by sequence7 on Monday September 16, 2013 @02:17PM
(#6394793)
Method 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?
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.