Wait Synchronization Technology Sample
For more information about using the samples, see the following topics:
To build the sample using the command prompt
Open the Command Prompt window and navigate to one of the language-specific subdirectories for the sample.
Type msbuild WaitSynchronizationCS.sln or msbuild WaitSynchronizationVB.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 WaitSynchronizationCS.sln or WaitSynchronizationVB.sln, depending on your choice of programming language, to open the file in Visual Studio.
On the Build menu, click Build Solution.
To run the sample
Navigate to the directory that contains the new executable file.
Type Mutex.exe from the command line.
This sample builds a console application. You must launch it from a console window to view its output.
This sample queues up five asynchronous method calls. Each method then waits to own the resource, writes to the console, sleeps, and then writes to the console a second time.
The following bullets briefly describe the technologies and classes used by this sample:
Mutex Provides mutual exclusion for thread synchronization.
WaitHandle The WaitHandle class is the base class from which both Mutex and AutoResetEvent classes (among others) are derived. This type implements methods to "wait" for the various derived types to go "signaled".
For more information about threading and synchronization, see the comments in the source code and build.proj files.