I have an ASP.NET Core application with an async method with a signature something like this.
public async Task RunAsync()
{
// ...
}
I'm concerned about this method running at the same time by more than one thread.
It looks like I can use lock or a SemaphoreSlim. Can someone help explain these options in a way that I can choose between the two?
Also, does the fact that my method is async impact the decision?
So, I don't know all the details of how these two methods work, but I found that you cannot use
awaitwithin alock. So even thoughlockappears to have some advantages, in my case, only aSemaphoreSlimwill work.