aquality-selenium-dotnet icon indicating copy to clipboard operation
aquality-selenium-dotnet copied to clipboard

Add possibility to use async/await in the tests

Open DmitryBogatko opened this issue 1 year ago • 0 comments

At the moment AquaityService uses ThreadLocal to keep AppContainer and ServiceProviderContainer instances. But it brings problems if you want to make your tests to be used in async context. To solve this we must use AsyncLocal instead https://learn.microsoft.com/en-us/dotnet/api/system.threading.asynclocal-1?view=net-8.0&redirectedfrom=MSDN

private static readonly ThreadLocal<TApplication> AppContainer = new ThreadLocal<TApplication>();
private static readonly ThreadLocal<IServiceProvider> ServiceProviderContainer = new ThreadLocal<IServiceProvider>();

DmitryBogatko avatar Jul 18 '24 11:07 DmitryBogatko