dotNet Threading, Part II Intermediate Level
This article is written for the intermediate and senior C# developer. Working knowledge of the C# programming language and dotNet framework is assumed. The article was written with a Beta version of VS.NET and associated documentation. Changes, although not anticipated, might occur before final release of VS.NET that invalidate portions of this article. In the first article, I discussed how to create threads, thread pools and some of the synchronization objects available in the System.Threading dotNet namespace. In this second article, I will complete my discussion of the synchronization objects and will discuss thread local storage, COM interoperability and thread states.
…
ReaderWriterLock
Another popular design pattern introduced as a class in the dotNet framework is the ReaderWriterLock. This class allows an unlimited amount of read locks or one write lock, but not both. This allows anyone to read the protected resource, as long as nobody is writing to the protected resource and allows only one thread to write to the protected resource at any one time. Listing 1 presents a sample using the ReaderWriterLock class.
…
Mutex
The last synchronization object I’ll present here is the Mutex. The most useful feature of the Mutex class is that it may be named. This allows you to create two Mutex objects in different areas of code without having to share Mutex object instances. As long as the Mutex object instances have the same name, they will synchronize with each other. You could create the Mutex in two different processes on the same machine and the synchronization crosses the process boundary. Nor do you have to worry about passing the Mutex object in order to share the synchronization object between two threads or methods (see Listing 2).
…
Website: www.kbcafe.com | Filesize: 150kb
No of Page(s): 8
Click here to download dotNet Threading, Part II Intermediate Level.
Related Tutorial
Tags: .NET, asynchronous delegates, autoresetevent, backgroundworker, exception handling, manualresetevent, mutex, ReaderWriterLock, semaphore, synchronization objects, thread pooling, threads
Comments
Leave a Reply