Reputation: 9937
I have a process within my MVC 2 application that takes a large amount of time and alters many rows in the database in the process.
There is a chance that two or more users could attempt to perform this action at the same time, which would lead to undesirable effects.
Is there a way to set a global flag somewhere within asp.net that I can check against all requests to see if the action in question is currently being executed? (a bit that I flip prior to running query, and then then flip back on completition)
Or is there a better way of handling this situation?
Thanks
Upvotes: 2
Views: 1192
Reputation: 499382
You can use the Application
object - it is part of the HttpContext
.
Upvotes: 3
Reputation: 3481
MVC is built on Asp.Net core. You can use Application object to store with proper locking.
Upvotes: 2