kusanagi kusanagi - 1 year ago 141
C# Question

watin multithreading

How can I work with Watin using async delegates? I tried, but it returned this error:

The CurrentThread needs to have it's ApartmentState set to ApartmentState.STA to be able to automate Internet Explorer.

Answer Source

I assume you use BeginInvoke() on your delegates. They use the thread pool to do threaded work and the threads in the thread pool are all MTA's. You will have to do it the old fashion way by creating your own Thread. The thread class offers methods (Get/SetApartmentState) to change the apartment model.

I guess you might need your own message pump as well in your thread.

Something like this might get you started:

var th = new Thread(() => { /* do work */ });


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download