I have WCF service and use useful feature to lock execution of code among any threads and instances of WCF. I use static variable in such way:
private static object _locker = new System.Object();
public void MyMethod()
{
lock(_locker)
{
//some code
}
}
Because static variables are shared across all WCF instances(are global for the life of the application) the code in lock block always executes only once at the same time - for all clients and all their requests.
Now I need to port such logic to .NET CORE platform. But WCF is not implemented in .NET CORE.
How can I make service using .NET CORE (maybe ASP.NET CORE) that would be able to lock code sections in such way and store variables among all requests ?