For long runnings tasks(Asynchronous) in C# 4.0 windows Application.
The choices are:
-
BackgroundWorker (Thread Pool)
-
Thread
The above two are recommended for long running tasks(throughout application lifetime). Any other choices? In Additon,
-
BackgroundWorker – Uses ThreadPool Thread and for long running process with UI updates.
-
Thread – User defined Thread (Thread Creation overhead etc.) and for long running process (can use priority)
Which would be a best choice
-
if no need for UI update,priority and for Thread (which is created only on application/process start)?
-
if number of tasks increased? (Care of ThreadPool Starvation)
-
Any other interesting things?
You would probably use a Task (TPL) with the LongRunning option. The TPL also runs on top of the ThreadPool but the option can make it reserve a thread.
The ThreadPool will try to dynamically adapt, and you have the option to help it a little.