This PR addresses two places where task pool threads would perform blocking waits, which is an anti-pattern that can easily lead to Thread Pool starvation. The first was a call to Thread.Sleep() which has been replaced by Task.Delay(). The second was a method that internally called Task.Wait(), the fix for which required converting the whole call chain leading to that code into asynchronous methods. This meant that the return type from StatsigClient.Shutdown() and StatsigServer.Shutdown() was changed from void to Task.
I also updated the list of target frameworks for the library to include .NET 6.0, and then took advantage of that framework's support for IAsyncDisposable. And finally, I dropped netcoreapp2.1 from the list of target frameworks as it is no longer supported by Microsoft, and any apps targeting that framework can use of the netstandard2.0 build of this library.
This PR addresses two places where task pool threads would perform blocking waits, which is an anti-pattern that can easily lead to Thread Pool starvation. The first was a call to
Thread.Sleep()
which has been replaced byTask.Delay()
. The second was a method that internally calledTask.Wait()
, the fix for which required converting the whole call chain leading to that code into asynchronous methods. This meant that the return type fromStatsigClient.Shutdown()
andStatsigServer.Shutdown()
was changed fromvoid
toTask
.I also updated the list of target frameworks for the library to include .NET 6.0, and then took advantage of that framework's support for IAsyncDisposable. And finally, I dropped netcoreapp2.1 from the list of target frameworks as it is no longer supported by Microsoft, and any apps targeting that framework can use of the netstandard2.0 build of this library.