The System.Threading namespace contains basic threading support: threads, mutexes and condition variables. It also contains support for processes and fibers.
Examples
This threadFunction example shows how to execute a function in a separate thread. Main function starts a thread that executes the ThreadFunction function, and waits the thread to end by calling the Join member function of the started thread. A thread function should handle all exceptions. Since all exceptions derive from the Exception class, handling it suffices.
This threadSynchronization example shows how to use LockGuard , RecursiveMutex and a ConditionVariable to synchronize threads. The main function starts first the Run member function of the OutputCollector class in a separate thread. Then it queries the number of cores by calling the HardwareConcurrency function, and starts twice as many output threads. The output threads enqueue message lines by calling the EnqueueLine member function of the OutputCollector . Finally main thread Join s the output threads and the output collector thread.
This third example shows how to transfer exceptions from a separate thread to the main thread.