John Spano cofounder and CTO of NeoTekSystems, a Greenville, South Carolina technology consulting company. NeoTekSystems offers IT consulting, custom programming, web design and web hosting. We specialize in Microsoft .Net enterprise development and business design.
I have six years of experience in software architecture. My primary focus is on Microsoft technologies, and I have been involved in .NET since beta 1. I currently hold a MCSD certification, 2 MCTS's (Windows, Web) a MCPD in Distributed, 2 MCITP's, a Microsoft MVP, and have won the Helper of the Month contest for July 2002 in the devCity.NET forums.
Corporate URL: www.NeoTekSystems.com
Primary email: JSpano@NeoTekSystems.com
View all articles by John Spano...
Alternate email: Jspano@devcity.net.
Multithreading, a very powerful technique, is essential for modern software development. Software users expect to work with a very responsive program that they don’t have to wait on, which is a very reasonable demand with the processor speeds that are currently available. Enter multithreading. Multithreading is the concept of having several different paths of code running at the same time.
When you introduce multithreading in your applications, you immediately make programming more complicated and add design time. You must know exactly what your application and all its threads are doing at all times. You have to account for deadlocks, race conditions and corrupting variable values. In this article we will examine the different methods in Visual Basic.Net to accomplish thread synchronization. We will learn what deadlocks and race conditions are and how to avoid these common problems with multithreading.
I will assume that you already have knowledge of basic threading in Visual Basic.Net. You should know how to create threads and know how to do basic threading operations like Join and Sleep. A copy of Visual Studio.Net is required to run the code samples and see the output. The code was written with Visual Studio.Net using version 1.0 of the .Net Framework with service pack 2.
Case Study Structure
This case study has three main parts. Multithreading requires a technique called synchronization to eliminate the problems described above so we will first take a brief look at what synchronization is. Then an in-depth look at all methods available in Visual Basic.Net for synchronization will be presented where you will learn how to correctly synchronize a multithreaded application. After this, a look at Window’s Form synchronization and threading apartment styles will show the differences a programmer must handle between standard synchronization and visual GUI synchronization.