Summary


This chapter took a fairly involved look at the subject of threading in .NET and demonstrated the rich set of threading functionality now available to Visual Basic developers.

Proper implementation of multithreaded code is very difficult, and proving that multithreaded code will always run as expected requires careful code walk-throughs, as it can’t be proven through testing. Due to this, it is best to avoid the use of multithreading when possible.

However, multithreading can be a useful way to run lengthy tasks in the background while continuing to provide the user with an interactive experience. When using multithreading, try to avoid using shared data, and instead relay data between the UI and background threads using messaging techniques, as shown in this chapter.

If you must share data between multiple threads, be sure to use appropriate synchronization primitives to ensure that only one thread interacts with the data at any given time. Be aware of the performance implications of using synchronization objects, and design carefully to avoid deadlocks.

Threading can be useful in specialized situations, and its use should be limited whenever possible.




Professional VB 2005 with. NET 3. 0
Professional VB 2005 with .NET 3.0 (Programmer to Programmer)
ISBN: 0470124709
EAN: 2147483647
Year: 2004
Pages: 267

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net