In Watin's source code, there is this piece of code:
public void NavigateToNoWait(Uri url)
{
var thread = new Thread(GoToNoWaitInternal);
thread.SetApartmentState(ApartmentState.STA);
thread.Start(url);
thread.Join(500);
}
[STAThread]
private void GoToNoWaitInternal(object uriIn)
{
var uri = (Uri)uriIn;
NavigateTo(uri);
}
Since the thread created has its apartment state set, why is the [STAThread]
attribute added to the method? I am not interested in the specific piece of code, but I am wondering if STAThread
attribute is needed at all.
Notes:
- The method
GoToNoWaitInternal
isn't used elsewhere. - The whole watin project is about manipulating WebBrowser objects (Internet explorer windows in general). Thus, we are manipulating a COM Object.