I have a C# Add-In for a UML modelling product that automatically draws diagrams and maintains them. I am processing larger scale enterprise models with over 6000 diagrams. This takes a long time (even on faster machines). So I created a version that uses the Background worker thread to run the "batch" portion of the job while the "foreground" has a modal dialogue that allows me to stop the processing early. Otherwise, due to the UI of the modelling program I can't send the "STOP" message to the Add-In.
The background version seems to take twice as long as the single thread version. Actually, I was expecting that the background worker thread version would be multi-threaded but from what probing I have been able to do it's not actually running in a separate thread.
The Modal dialog and the Add-In communicate correctly so the two pieces of functionality appear to be on separate threads. The batch runs under .RunWorkerAsync() through the DoWork method. But if I place traces in the code they report that there are not running on separate threads (since .Invoke Required is set to false).
I would have expected a small amount of overhead, but not this much (100%).
What's going on? Should I be moving to true multi-threading (as opposed to BackgroundWorker)?
TIA, Paolo