BackgroundWorker is a class that was introduced with in Windows Forms 2.0 to simplify executing work on background threads allowing UI developers to easily keep their UIs responsive by not tying up the UI thread. It’s a tool that was very useful and if you don’t already know then you’ll probably be very pleased to find out that you can still use BackgroundWorker in WPF. This is because BackgroundWorker uses AsyncOperationManager which in turn uses SynchronizationContext to marshall work. In Windows Forms AsyncOperationManager gets a WindowsFormsSynchronizationContext class from the Forms application that derives from the SynchronizationContext class and uses it for marshalling. When using WPF a DispatcherSynchronizationContext is fetched by AsyncOperationManager which allows for easy marshalling of calls to background threads using BackgroundWorker.
Posts Tagged ‘Threading’
Using BackgroundWorker with WPF
Tuesday, December 8th, 2009Hosting WorkflowRuntime 3.5 as a Windows Service
Monday, November 16th, 2009Hosting in a windows service has a few gotcha’s to it as I found out on my first WF project and I wanted to share those here to hopefully help others to get things running much quicker than I did.