Visual Basic 2005 for Programmers (2nd Edition)
15.10. Wrap-Up
In this chapter, you learned the capabilities of the .NET framework that enable you to specify concurrent tasks in your programs. We discussed how to create threads of execution using class Thread and ThreadStart delegatesboth from the System.Threading namespace. We discussed several applications of concurrent programming. In particular, you learned about problems that may occur when multiple threads share the same data. To emphasize these issues, we presented an unsynchronized example of the producer/consumer relationship in which a producer thread placed values in a shared buffer and a consumer thread consumed those values. We then demonstrated the producer/consumer relationship again and showed how to synchronize threads using the capabilities of class Monitor. This ensured that the shared data was accessed and manipulated properly by the producer and consumer threads. You also learned how to enable threads to operate more efficiently by using a circular buffer that provided extra locations in which the producer could place values and from which the consumer could retrieve those values. Next, you learned that GUI components are not thread safe, so all changes to GUI components should be performed in the user interface thread that creates and maintains the GUI. We showed how to use Control method Invoke and a delegate to allow a thread to specify the tasks the user interface thread should perform on GUI components. This enabled multiple threads to modify GUI components in a thread-safe manner. In the next chapter, you will learn about the .NET framework's string, character and regular expression processing capabilities. |
Категории