2 ms·
> You don't need to build two library APIs. You can just build an Async method as the default implementation then have a blocking call to that as the synchronou
by caleblloyd 10y ago
> You don't need to build two library APIs. You can just build an Async method as the default implementation then have a blocking call to that as the synchronous method
This can lead to a nasty problem: Thread Pool Starvation. I contribute to MySqlConnector, an MIT Licensed MySql driver for .NET that implements truly Asynchronous I/O. We did this at first, but had to do a large refactor because we hit Thread Pool Starvation in our high concurrency performance tests. Here's the original issue: https://github.com/mysql-net/MySqlConnector/issues/62 https://github.com/mysql-net/MySqlConnector/issues/62
Stephen Toub has a pretty good article explaining why you shouldn't do "Sync over Async": https://blogs.msdn.microsoft.com/pfxteam/2012/04/13/should-i-expose-synchronous-wrappers-for-asynchronous-methods/ https://blogs.msdn.microsoft.com/pfxteam/2012/04/13/should-i...