BackgroundWorker in Excel 2007 Managed Add-In

C

Chris Herring

I'm trying to use a background worker to execute a query and then display
the results in Excel in the workers RunWorkerCompleted event (similar to was
PivotTables do when you click "Show Details" on a cell).
Initially I had a problem that the RunWorkerCompleted event was not
executing on the main thread. I managed to get around this by using a
suggestion I found on the net, inserting the following call before calling
RunWorkerAsync:
AsyncOperationManager.SynchronizationContext = New
WindowsFormsSynchronizationContext()
Now the RunWorkerCompleted event runs on the main thread ok however if the
user is performing an action e.g. typing, when the worker thread completes
then any action that changes Excel in RunWorkerCompleted will raise a COM
exception. It does not wait for the user to complete their action before
calling the completed event.
Any suggestions on how to get around this issue?

Thanks
Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top