statsig-io / dotnet-sdk

Statsig SDK for .NET applications on both client and server sides
ISC License
2 stars 6 forks source link

Get rid of blocking waits on task pool threads #6

Closed kroymann closed 2 years ago

kroymann commented 2 years ago

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.