Posted on: 3/2/2015 11:29:19 PM | Views : 588

Hello,
I have a function "somefunction" which is triggered by a Page_Load event.
The thing is that I want to restrict so this function only can be run one at a time. For example if many pages would be open, I don't want all Page_Loads to access this function but they will need to come one after the other. The task will not take more than 1 minute to complete.
How can a Mutex be used in this scenario. I am not exactly sure how we can use a Mutex in ASP.net
protected void Page_Load(object sender, EventArgs e) { Thread thread = new Thread(backgroundWORKER); thread.Start(); } public void backgroundWORKER() { //How to assure that this function only can be accessed one at a time? somefunction somefunction = new somefunction(); somefunction.dosomething(); }

Go to the complete details ...