Поделиться через


Threading Objects and Features

Microsoft Silverlight will reach end of support after October 2021. Learn more.

The .NET Framework provides a number of objects that help you create and manage multithreaded applications. Managed threads are represented by the Thread class. The ThreadPool class provides easy creation and management of multithreaded background tasks. The BackgroundWorker class does the same for tasks that interact with the user interface. The Timer class executes background tasks at timed intervals.

In addition, there are a number of classes that synchronize activities of threads, including Monitor, Interlocked, and the classes derived from EventWaitHandle. The features of these classes are compared in Synchronization Primitives.

In This Section

  • The Managed Thread Pool
    Explains the ThreadPool class, which enables you to request a thread to execute a task without having to do any thread management yourself.

  • Timers
    Explains how to use a Timer to specify a delegate to be called at a specified time.

  • Monitors
    Explains how to use the Monitor class to synchronize access to a member or to build your own thread management types.

  • Wait Handles
    Describes the WaitHandle class, the abstract base class for event wait handles, which enables waiting for multiple synchronization events.

  • EventWaitHandle, AutoResetEvent, and ManualResetEvent
    Describes managed event wait handles, which are used to synchronize thread activities by signaling and waiting for signals.

  • Interlocked Operations
    Explains how to use the Interlocked class to increment or decrement a value and store the value in a single atomic operation.

  • Synchronization Primitives
    Compares the features of the .NET Framework classes provided for locking and synchronizing managed threads.

Reference

  • Thread
    Provides reference documentation for the Thread class, which represents a managed thread, whether it came from unmanaged code or was created in a managed application.

  • BackgroundWorker
    Enables background tasks that interact with the user interface, communicating via events raised on the user-interface thread.