I have tried to access a GUI element (a ToolStripStatusLabel) from inside a STA thread. Im having all sorts of issues trying to get invoke on it, thats becuase now i know there is no invoke for ToolStripStatusLabel, my latest error is: Error 1 'System.Windows.Forms.ToolStripStatusLabel' does not contain a definition for 'Invoke
I cant seem to update it without invoke for i get the error: System.NullReferenceException' occurred
What are my options here? How would i go about doing this, changing the statuslabel.text on the GUI thread from inside a STA thread.
I have used all manors of standard invoke code and control extensions found here but still the same issues.
CODE AS REQUESTED:
private void buttonclick(object sender, EventArgs e)
{
CheckForIllegalCrossThreadCalls = false;
var thread = new Thread(() =>
{
var ie = watinBrowser();
log("[!] Starting Application");
log("blahblah");
});
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
}
private void log(string logIt)
{
statusUpdate(logIt);
}
private void statusUpdate(string text)
{
if (this.statusStrip1.InvokeRequired)
{
this.statusStrip1.Invoke(new MethodInvoker(() => this.toolStripStatusLabel1.Text = text));
}
else
{
this.toolStripStatusLabel1.Text = text;
}
}