I Have try this. https://stackoverflow.com/a/142069/2126472
like toolStripStatusLabel1.InvokeRequired
but toolStripStatusLabel1
has no InvokeRequired
and I has try this too. https://stackoverflow.com/a/15831292/2126472
and it error like invalid argument on
SetTextCallback d = new SetTextCallback(SetText);
form.Invoke(d, new object[] { form, ctrl, text });
when I use
ThreadHelperClass.SetText(this, toolStripStatusLabel1, "This text was set safely.");
but not error when I use textBox
My code have method that wait for bool
from another method that use Thread to run in background.
Thread t = new Thread(TestRemoteDB);
t.Start();
// In TestRemoteDB() will call updateRemoteDBStatus()
like this
private void updateRemoteDBStatus(bool successful)
{
if (successful)
{
toolStripStatusLabel4.Text = "OK!";
toolStripStatusLabel4.ForeColor = Color.Green;
}
else
{
toolStripStatusLabel4.Text = "Error!";
toolStripStatusLabel4.ForeColor = Color.Red;
}
}