----------------------------------------------------------- New Message on BDOTNET
----------------------------------------------------------- From: bradpitt889 Message 2 in Discussion Hi Shiv, Multithreaded application usually has resources that can be accessed from multiple threads; for example, a global variable that is incremented or decremented by multiple threads. It is sometimes desirable to prevent multiple threads from concurrently altering the state of a resource. The .NET Framework includes several classes and data types that we can use to synchronize actions performed by two threads. The simplest case is if we have a shared variable that we need to update from different threads. To do this, we can use the System.Threading.Interlocked class. For example, to increment or decrement the shared variable called num, we'd write Interlocked.Increment(num) or Interlocked.Decrement(num). we can also use Interlocked to set the variables to a specific value or to check the equality of two variables. The advantage is that the two methods operate in an "atomic" manner meaning that the methods take an integer, increment (or decrement) it and return its new value, all in one step. You can also use this class to set the variables to a specific value (done with Interlocked.Exchange method) or to check the equality of two variables, if they are equal, replaces one of the variables with a given value (Interlocked.CompareExchange method). <O:P></O:P> <O:P> </O:P> Regards Kunal ----------------------------------------------------------- To stop getting this e-mail, or change how often it arrives, go to your E-mail Settings. http://groups.msn.com/bdotnet/_emailsettings.msnw Need help? If you've forgotten your password, please go to Passport Member Services. http://groups.msn.com/_passportredir.msnw?ppmprop=help For other questions or feedback, go to our Contact Us page. http://groups.msn.com/contact If you do not want to receive future e-mail from this MSN group, or if you received this message by mistake, please click the "Remove" link below. On the pre-addressed e-mail message that opens, simply click "Send". Your e-mail address will be deleted from this group's mailing list. mailto:[EMAIL PROTECTED]
