Search code examples
c#thread-safetymultithreadingtoolstrip

Setting a ToolStripLabel in a thread-safe manner


I have a ToolStripLabel that needs to have its Text property updated from an event handler on a separate thread. Normally with a regular Label I've been using the InvokeRequired property and invoking a delegate to do the work if InvokeRequired returns true. The trouble is that ToolStripLabel doesn't have this property. What is the cleanest way to get this text updated in a thread-safe manner?


Solution

  • Use the InvokeRequired on the ToolStrip control instead of the ToolStripLabel.