المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Running a BackgroundWorker in a Single Threaded Apartment



C# Programming
04-13-2010, 10:21 PM
So, I have been working on a project to allow me to query an OLAP data cube from within another program. I built a form that I use to connect to the cube, pull out the information for the user to select from, and then it creates the query.

It works great as a stand-alone application. The info is loaded using a BackgroundWorker and updates the UI as the loading completes certain levels (it can take up to a minute to load the entire cube's dimensions and lower levels.

My problem is that I built it to work in a program, that I now discover runs in a Single Threaded Apartment. Within that environment, the BackgroundWorker.DoWork event never gets called. I did a little test using the Threading.Thread model and that seems to work the way I would expect.

My question is, does anyone know why the BackgroundWorker wouldn't work within an STA and is there a way around it without rewriting my code to switch from a BackgroundWorker to the Threading.Thread model?