I am using Watin inside Task which throw exception
ThreadStateException with an error message of 'The CurrentThread needs to have its ApartmentState set to ApartmentState.STA to be able to automate Internet Explorer'
My code is look like
Task task = Task.Factory.StartNew(() =>
{
try{
string Url="www.google.com";
IE ie = new IE(Url);
}
catch (Exception ex)
{
throw ex; //ThreadStateException
}
});
How can i solve this problem?
I am trying to google but unable to find solution.