Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to deal with the critical region in the programming language C #. Is there an example of this case
Or reference explaining that
Posted
Updated 3-May-12 6:20am
v2
Comments
wizardzz 3-May-12 12:56pm    
I have no idea what you are asking.
Sergey Alexandrovich Kryukov 3-May-12 13:21pm    
Reason for my vote of 1
Not clear. Not a valid question. What do you mean by critical region? What is the question.
--SA

1 solution

Do you mean anything like a critical section, to make you're code threadsafe?

Then the lock keyword in c# will help you.

C#
public ThreadSafeClass
{
   object criticalSection = new object();

   public void SomeMethod()
   {
     lock(critialSection)
     {
       // you're synchronization critical stuff goes here..
     }
   }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900