I have a long running series of operations in a .NET 2.0 BackgroundWorker thread. When I make a call to unmanaged code located in a referenced assembly the UI is frozen until the call completes.
Why is this? Should I not be making these calls from the BackgroundWorker thread?
Yes, it is a COM component but I’m not sure how to tell if it’s STA or not and what the implications/resolution are/is. I make several calls to that component but it is only the long-running ones where I notice the UI becoming unresponsive.
These calls retrieve data from a server.
You’ve got the COM tag in the question – are you calling into a COM component? Is it an STA component? If so, it may well be marshalling back to do its work on the UI thread somehow. I’ll readily admit I’m a long way from being an expert on COM stuff, but I wouldn’t be surprised if that were the problem.
What happens if you make the calls from a new thread which you’ve explicitly created?