Skip to main content
8 events
when toggle format what by license comment
Dec 6, 2018 at 22:35 comment added supercat If an operation should be performed synchronously, it's better to use a method that knows that it's doing the operation synchronously, than to start an asynchronous operation and wait for it to complete. For quick operations, the time required to set up everything necessary to schedule the operation and process the notification may exceed the time that would be required to simply do the operation.
Dec 6, 2018 at 20:49 comment added Carl Walsh @Neil if an interface exposes an asynchronous method, expecting that waiting on the Task won't create a deadlock isn't a good assumption. It's much better for the interface to show it is actually synchronous in the method signature, than a promise in the documentation that could change in a later version.
Dec 6, 2018 at 0:36 comment added Miral It really is trivial to convert async to sync. But you have to be careful about which thread you're blocking, and you can only do it at most once in any particular call graph -- if you have multiple layers mixing up synchronous and asynchronous calls, then you are in for a world of pain.
Dec 5, 2018 at 16:54 comment added NickL @Neil In javascript, even if you call Promise.resolve(x) and then add callbacks to it, those callbacks won't be executed immediately.
Dec 5, 2018 at 10:26 comment added Ewan yeah its totally a pain in the arse to convert async back to sync
Dec 5, 2018 at 10:25 comment added Neil @max630 I didn't say there aren't concurrent issues to consider, but if it was initially a synchronous task, chances are it's not creating deadlocks. That said, trivial does not mean "double click here to convert to synchronous". In js, you return a Promise instance, and call resolve on it.
Dec 5, 2018 at 10:00 comment added max630 "At runtime, to convert an async call to a synchronous one is trivial" I'm not sure it is exactly so. In .NET, using .Wait() method and like can cause negative consequences, and in js, as far as I know, it is not possible at all.
Dec 5, 2018 at 9:16 history answered Neil CC BY-SA 4.0