Hi Geert,
Thanks for your answer.
It works pretty well for things like doing a lot in the background. I've already done such things, and I'm happy with this. A lot of short-running EA API calls are no issue.
Sadly, this approach doesn't work for a long-lasting API call to EA COM-Object like 'repository.SqlQuery()', which, in my case, may need minutes to complete. During the time to complete the method call, the main thread with the GUI is blocked by the BackgroundWorker. After the call, the main thread can run until the following API call to COM occurs.
In the meantime, I've googled and tested a bit.
Using the EA COM-Object (Repository) runs in a STAThread, which essentially states that this is a thread-unsafe call.
The BackgroundWorker is a MTA thread. The MTA background thread blocks the main thread until the call is finished to ensure that the thread-unsafe COM object will not cause any harm.
That's what I have understood.
The solution could be:
Making an own STAThread as a background thread.
I made a little test and confirmed the blocking of the main thread and the thread types (main: STAThread, background: MTA).
It all looks a little complicated and unpredictable (Thread handling,
?)
Best regards,
Helmut