<a href="http://www.micropoll.com/akira/mpview/585320-168921">Click Here for Poll</a><a href="http://www.questionpro.com" title="online surveys">Online Survey</a><BR> | <a href="http://www.micropoll.com" title="Website Polls">Website Polls</a><BR> | <BR><a href="http://www.micropoll.com/akira/MicroPoll?mode=html&id=168921">View MicroPoll</A></div>

Visual Studio 2010!

Read now >

Windows Mobile Development Thoughts

Read now >

View Now
DevSource RSS FEEDS
XML Want an easy way to keep up with breaking tech news? And the Get DevSource headlines delivered to your desktop with RSS.
ADVERTISEMENT
ADVERTISEMENT

 

DevSource.com: Your Source for Visual Studio on Facebook
ADVERTISEMENT
What's New in Whidbey's Threading
By Max Loukianov

Rate This Article: Add This Article To:

What's New in Whidbey's Threading - ' '
( Page 3 of 3 )

What's New in Whidbey Threads">

What's New in Whidbey Threads

Whidbey has added some methods, classes, and functionality to threading support in .NET. Here are the most significant additions.

The ThreadPool class has added SetMaxThreads(int workerThreadCount, int ioThreadCount), so now we can set the maximum thread count for the thread pool. In previous versions of the .NET Framework, the number of threads in a thread pool was fixed at 25 times the number of processors. Now you have the flexibility to set your own thread pool size. Use it wisely!

Whidbey adds a ParametrizedThreadStart class to System.Threading. ParameterizedThreadStart allows a passing parameter to start a method of a thread, without requiring you to write additional code.

Finally, the .NET Framework has semaphores! There is now a Semaphore class that provides exactly the same functionality as did semaphores in the Win32 API.

If you became familiar with the critical sections and thread affinity concepts from Win32, some new methods in the Thread class will look familiar. Those are: BeginCriticalSection and EndCriticalSection and BeginThreadAffinity and EndThreadAffinity. However, those methods have nothing to do with processor hard real-time processing and processor affinity (as it was in Win32). Instead, you use BeginCriticalSection and EndCriticalSection to tell the .NET CLR that the thread is currently in a critical section, and an abort or unhandled exception would bring the whole AppDomain down. Interestingly, BeginThreadAffinity and EndThreadAffinity are used to signal to the CLR that .NET thread should not be moved from one physical thread to another, because it is dependent on the underlying physical thread. I guess .NET applications really run in a virtual machine, and have no idea about underlying hardware!

Syncronization primitives, such as Mutex, Semaphore, and EventWaitHandle have some new static members in Whidbey. The SignalAndWait static member allows an atomic signal on one thread, and a wait on another. The OpenExisitng method allows you to create and open an existing named version of the same primitive.

The Interlocked class has gained some methods, too: Read(ref long location), Exchange, and Add. Read performs an atomic read on a "64-bit" value; Exchange will exchange doubles, longs, and IntPtrs; and Add atomically add svalues to integers and longs.

Finally, ExecutionContext has gotten a whole bunch of new additions, far too many for me to discuss here. Right now, your best resource to learn about thosse is the Whidbey community documentation.



 
 
>>> More Using Microsoft Visual Studio Articles          >>> More By Max Loukianov