Join Thread Technology Sample
This sample demonstrates the common language runtime threading feature that allows one thread to wait for the termination of, or "join", another thread. The sample creates a second thread and starts it running on a static method of the App class. The primary thread then waits for the second thread to finish by calling the Join method.
Review comments in the source code files for more information on threading.
For more information about using the samples, see the following topics:
To build the sample using the command prompt
Open a Command Prompt window and navigate to one of the language-specific subdirectories for the sample.
Type msbuild JoinThreadCS.sln or msbuild JoinThreadVB.sln, depending on your choice of programming language, at the command line.
To build the sample using Visual Studio
Open Windows Explorer and navigate to one of the language-specific subdirectories for the sample.
Double-click the icon for JoinThreadCS.sln or JoinThreadVB.sln, depending on your choice of programming language, to open the file in Visual Studio.
In the Build menu, click Build Solution.
To run the sample
Navigate to the directory that contains the new executable, using the Command Prompt.
Type JoinThread.exe at the command line.
Note
This sample builds a console application. You must launch and run it in a Command Prompt window to view its output.
Remarks
The following bullets briefly describe the technologies and classes used by this sample:
Thread Synchronization
- Thread The sample first creates a new thread and calls its Start method. Then the sample uses the Join method to wait for the new thread to terminate. If not, a race condition would occur between the two threads. If this were to happen, the second thread might not be able to finish processing before the application exits.
Delegates
- ThreadStart Used to create a typesafe callback method for the thread.