Cant update StatusStrip items from working thread

B

Benny

I have a GUI and a working thread. I have used just regular labels and
used callbacks to update the text on the GUI thread until now. I have
added a status bar with 2 labels i need to be able to change and 1
status bar. None of the actual items on the status bar have a
"InvokeRequired" property and i have tried using the actual status
bar's "InvokeRequired" but i get a nullreference exception. I have
checked all the local variables and none of them are null nothing is
making sense so if someone could show me the light on how to update the
status bar items i would greatly appreciate it! Thanks in advance!
 
D

Dan Manges

Hi,

I would try Invoke'ing a method on the form which updates the status
bar. The code would be something like this (not tested):

public MyForm : Form
{
private delegate void NoArgCallback();

private void UpdateStatusBar()
{
//code here
}

private void MethodRunningInThread()
{
NoArgCallback callback = new NoArgCallback(UpdateStatusBar);
this.Invoke(callback);
}
}

You should be able to Invoke on the form like that and then update the
status bar from there.

Hope this helps.

Dan Manges
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top