Reputation: 4615
In MVC if I want to lock a method so that it will never run more than once at a time (despite multiple users using the application), I can just use a static object:
private static Object lock= new Object();
But in my case I want to create a lock with a name, so the application will only lock for those users trying to use the same name.
Normally in C# I would use a Mutex(name) for this, but is there an appropriate equivalent in server world? (it needs to be global for all users)
Edit:
This is a client application, rather than a public site - so there would only ever be max say, 20 users accessing the application at a time.
Upvotes: 0
Views: 680
Reputation: 62276
You do not want to block anything on server side, what you want is to not execute anything on server side once condition is met. It can be handled in number of ways: Error page redirection, Notification to the client about critical condition met...etc
In other words, for selected users, handle that special condition, but do not block anything.
Upvotes: 6