This is a small post about refactoring lock statements in async methods.
Before refactoring we had a code like this:
result = methodToRefactorIntoAsync();
private object sync = new object();
Lock is bound to a thread, thus no way you to use it in async code. As an alternative you may use SemaphoreSlim class:
result = await methodAsync(cancellationToken);
private SemaphoreSlim sync = new SemaphoreSlim(1, 1);
a@href@title, b, blockquote@cite, em, i, strike, strong, sub, super, u