TPL-like library for .NET 2.0

2019-07-04 00:08发布

问题:

After discovering the Parallels library in .NET 4.0, I'd like to have something similar in my .NET 2.0 application.

Are there any parallel programming helper libraries for .NET 2.0, that simplify common tasks?

回答1:

Threadpool would be a nomination in .NET 2.0 which is kind of similar with TPL.

Provides a pool of threads that can be used to execute tasks, post work items, process asynchronous I/O, wait on behalf of other threads, and process timers.

TPL actually uses Threadpool under the hood:

TPL handles the partitioning of the work, the scheduling of threads on the ThreadPool, cancellation support, state management, and other low-level details.



回答2:

You can try the BackgroundWorker class which has been available from .NET Framework 2.0+. There is a lot of information available on how to use this class both on this site and on MSDN.

You can also look at the Thread class, which has been available from .NET Framework 1.1+. There is also a wealth of information on this class. One resource I particularly like is J. Albahari's page on threading. This should provide a great starting point for you to get started with these features.

I hope this helps.