I have an application that performs a lot of busy work. All of the work is performed using a BackgroundWorker and the point of execution is the DoWork Event of the BackgroundWorker.
On the UI thread, before the workload begins, I display a PictureBox that contains an animated GIF that illustrates progress; for the most part this works fine and the UI thread is not paused or slowed while the BackgroundWorker does its job. There is however, one instance where the UI thread is impacted by the work being done and it defeats the whole purpose of putting this work in a separate thread. In this application, the user must wait until the work completes before they can move to the next step, so my sole reason for moving this all to a BackgroundWorker was so that I could display a smooth, uninterrupted progress indicator on the UI thread while this work was being done, so that the user could see that something was happening.
The case where the work being done is impacting the UI thread (pausing/delaying the PictureBox animation) deals with a referenced COM object.
I have the following declared in my form:
vb.net Code:
Private WithEvents oCOMObject as X
The COM object performs some processing when given a list of files and it is here where the majority of the lag takes place. In my BackgroundWorker's DoWork Event I have the following:
vb.net Code:
'instantiate the COM object oCOMObject = New X 'process the list of images (oFileList is a list of file paths on the system) oCOMObject.ProcessFiles (oFileList) 'it is here that the UI thread is delayed
All of the COM object event handlers and subsequent functions are appropriately using Delegates, but I am not sure why the ProcessFiles method would cause the UI thread to hang while the work completes; I thought that was the whole purpose of the BackgroundWorker.
Am I missing something? Any thoughts?
Thanks!

