How to run something in the STA thread?

You can start STA Threads like so: Thread thread = new Thread(MethodWhichRequiresSTA); thread.SetApartmentState(ApartmentState.STA); //Set the thread to STA thread.Start(); thread.Join(); //Wait for the thread to end The only problem is that your result object must be passed along somehow.. You can use a private field for that, or dive into passing along parameters into threads. … Read more

Single-threaded apartment – cannot instantiate ActiveX control

The problem you’re running into is that most background thread / worker APIs will create the thread in a Multithreaded Apartment state. The error message indicates that the control requires the thread be a Single Threaded Apartment. You can work around this by creating a thread yourself and specifying the STA apartment state on the … Read more

STAThread and multithreading

Apartment threading is a COM concept; if you’re not using COM, and none of the APIs you call use COM “under the covers”, then you don’t need to worry about apartments. If you do need to be aware of apartments, then the details can get a little complicated; a probably-oversimplified version is that COM objects … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)