Invoking components
Does anyone have any ideas how to make calls to these items thread-safe?
Thanks for any info.
-Jason
Does anyone have any ideas how to make calls to these items thread-safe?
Thanks for any info.
-Jason
I actually found a simple solution. Instead of testing for InvokeRequired on the ToolStripButtons and ToolMenuItems, I checked the InvokeRequired property of the actual ToolStrip and MenuStrip items themselves. After that, it seemed to work perfectly.
Example:
Delegate Sub ChangeButtonDelegate(ByVal Item as ToolStripButton)
Private Sub ChangeButton(ByVal Item as ToolStripButton)
If ToolStrip1.InvokeRequired Then
Dim d as New ChangeButtonDelegate(AddressOf ChangeButton)
Me.Invoke(d, Item)
Else
Item.Enabled = Not (Item.Enabled)
End If
End Sub
Works just fine!
-Jason