受控執行緒處理的基本概念Managed threading basics

本節的前五個主題專門設計來協助您判斷何時使用受控執行緒處理,並說明一些基本功能。The first five topics of this section are designed to help you determine when to use managed threading and to explain some basic features. 如需提供額外功能的類別相關資訊,請參閱執行緒物件和功能同步處理原始物件概觀For information on classes that provide additional features, see Threading Objects and Features and Overview of Synchronization Primitives.

本節的其餘主題將涵蓋進階主題,包括受控執行緒與 Windows 作業系統的互動。The rest of the topics in this section cover advanced topics, including the interaction of managed threading with the Windows operating system.

注意

在 .NET Framework 4 中,工作平行程式庫和 PLINQ 提供適用於多執行緒程式中工作和資料平行處理原則的 API。In the .NET Framework 4, the Task Parallel Library and PLINQ provide APIs for task and data parallelism in multi-threaded programs. 如需詳細資訊,請參閱平行程式設計For more information, see Parallel Programming.

本節內容In this section

執行緒和執行緒處理Threads and Threading
討論多個執行緒的優點和缺點,並概述您可能會建立執行緒或使用集區執行緒的案例。Discusses the advantages and drawbacks of multiple threads, and outlines the scenarios in which you might create threads or use thread pool threads.

Managed 執行緒中的例外狀況Exceptions in Managed Threads
描述適用於不同 .NET Framework 版本之未處理例外狀況的行為,特別是它們會導致應用程式終止的情況。Describes the behavior of unhandled exceptions in threads for different versions of the .NET Framework, in particular the situations in which they result in termination of the application.

同步處理多執行緒處理的資料Synchronizing Data for Multithreading
描述用來同步處理將與多個執行緒搭配使用之類別中的資料的策略。Describes strategies for synchronizing data in classes that will be used with multiple threads.

前景和背景執行緒Foreground and Background Threads
說明前景和背景執行緒之間的差異。Explains the differences between foreground and background threads.

Windows 中的 Managed 和 Unmanaged 執行緒處理Managed and Unmanaged Threading in Windows
討論受控和非受控執行緒之間的關聯性、針對 Windows 執行緒 API 列出受控對等項目,並討論 COM Apartment 和受控執行緒的互動。Discusses the relationship between managed and unmanaged threading, lists managed equivalents for Windows threading APIs, and discusses the interaction of COM apartments and managed threads.

執行緒區域儲存區:執行緒相關的靜態欄位和資料位置Thread Local Storage: Thread-Relative Static Fields and Data Slots
描述執行緒相關的儲存機制。Describes thread-relative storage mechanisms.

參考資料Reference

Thread
提供 Thread 類別的參考文件,不論這個類別是來自 Unmanaged 程式碼或是在 Managed 應用程式中建立,都會代表 Managed 執行緒。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
提供一個安全方式,搭配使用者介面物件來實作多執行緒。Provides a safe way to implement multithreading in conjunction with user-interface objects.

同步處理原始物件概觀Overview of Synchronization Primitives
描述用來同步處理多個執行緒活動的受控類別。Describes the managed classes used to synchronize the activities of multiple threads.

Managed 執行緒處理的最佳實施方針Managed Threading Best Practices
描述使用多執行緒的常見問題以及避免發生問題的策略。Describes common problems with multithreading and strategies for avoiding problems.

平行程式設計Parallel Programming
描述工作平行程式庫和 PLINQ,其可大幅簡化建立非同步和多執行緒 .NET Framework 應用程式的工作。Describes the Task Parallel Library and PLINQ, which greatly simplify the work of creating asynchronous and multi-threaded .NET Framework applications.