Replaces the standard BackgroundWorker provided by the .NET Framework to fix what seems to be a bug causing the BackgroundWorker to fire events in the wrong thread.
We have encountered cases where the BackgroundWorker seems to lose track of the main thread or just arbitrarily decide to fire ProgressChanged and RunWorkerCompleted in a new thread rather than in the main thread. This causes synchronization errors. This replacement class allows the client to specify a ISynchronizeInvoke synchronizer object through which the events will be fired. All Controls implement ISynchronizeInvoke, so any Control should be adequate to act as a synchronizer to invoke the events in the main thread.
Protected Member Functions |
|
override void | OnProgressChanged (ProgressChangedEventArgs e) |
Overrides the base OnProgressChanged to
invoke ProgressChanged events in the Synchronizer's thread.
|
|
override void | OnRunWorkerCompleted (RunWorkerCompletedEventArgs e) |
Overrides the base OnRunWorkerCompleted to
invoke RunWorkerCompleted events in the Synchronizer's thread.
|
|
Properties |
|
ISynchronizeInvoke |
Synchronizer [get, set] |
The synchronizing context. |
override void CSharpUtilities::SynchronizingBackgroundWorker::OnProgressChanged | ( | ProgressChangedEventArgs | e | ) | [inline, protected] |
Overrides the base OnProgressChanged to invoke ProgressChanged events in the Synchronizer's thread.
e | EventArgs containing data for ProgressChanged listeners. |
override void CSharpUtilities::SynchronizingBackgroundWorker::OnRunWorkerCompleted | ( | RunWorkerCompletedEventArgs | e | ) | [inline, protected] |
Overrides the base OnRunWorkerCompleted to invoke RunWorkerCompleted events in the Synchronizer's thread.
e | EventArgs containing data for RunWorkerCompleted listeners. |
ISynchronizeInvoke
CSharpUtilities::SynchronizingBackgroundWorker::Synchronizer
[get, set] |
The synchronizing context.
If this object is given a Synchronizer, ProgressChanged and RunWorkerCompleted events will occur in the Synchronizer's thread.