1

I am developing an application in which a data is received from SerialPort. This data is updated on a TextView. I use the following code from another class.

_displayWindow.Invoke(new EventHandler(delegate
{
  _displayWindow.SelectedText = string.Empty;
  _displayWindow.AppendText(msg);
  _displayWindow.ScrollToCaret();
}));

But now I will not put it in a TextView, this data will be placed in a ToolStripLabel but ToolStripLabel it has no Invoke .

Is there a way to update ToolStripLabel?

UPDATE: This is the complete method

private void DisplayData(string msg)
{
  _displayWindow.Invoke(new EventHandler(delegate
  {
     _displayWindow.SelectedText = string.Empty;
     _displayWindow.AppendText(msg);
    _displayWindow.ScrollToCaret();
  }));
}

I work in Framework 4.5

carson314
  • 339
  • 2
  • 5
  • 20

1 Answers1

0

How about:

this.BeginInvoke((MethodInvoker)delegate
{
    // update toolstriplabel here
});

I don't know your framework version. I found this link that could be of interest for you: How to update the GUI from another thread in C#?

Community
  • 1
  • 1
jmelhus
  • 1,130
  • 2
  • 12
  • 28