There is (almost) no reason to use the old Thread class anymore.
Similarly, the Background Worker class has seen its heyday. However, BGW does have one benefit over the TPL: it is easier to use for background tasks that need to report progress to the UI. Some of them update the UI infrequently, and can be easily broken into separate tasks which only update at each “checkpoint.” Other background tasks update the UI more frequently, and cannot be easily divided this way.
If you don’t want to read how this actually works and just want to get the source and start playing ,here is the Source Code.
Your WPF application may need to perform intensive tasks that consume large amounts of time.
Should we still blunder ahead, ignoring the end user, Windows will publicly dump us, by displaying a ‘kill process’ dialog to the user.
Uh, I may have been transferring my emotions there a bit…
The caller of the asynchronous method passes in the progress reporter, so it has complete control of how progress reports are handled.
Now let’s look at the “receiving” side of progress reports.The code in the Do Work event handler is executed on a separate thread.Providing Parameters to the Process Your background process may required one or more parameters, such as the address of a file to download. In this post we’ll be covering how to implement progress bars in your own application, and how to multi-thread your Power Shell applications so they don’t hang when background operations take place.If thing’s don’t improve, Windows will then gray out our whole application window to show the world what a bad boyfriend we are.If you’ve followed this series, you should know how to make some really cool applications, using WPF for the front-end and Power Shell for the code-behind. The goal here is to ensure that our applications DON’T do this. if we are running all operations in the same thread, from rendering the UI to code behind tasks like waiting for something slow to finish, eventually our app will get stuck in the coding tasks, and the UI freezes while we’re waiting. Windows will notice that we are not responding to the user’s needs and that we’re staying late at the office too often and put a nasty ‘Not Responding’ in the title.