المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : threading access to toolstripmenuitem



C# Programming
11-10-2009, 08:12 PM
I'm trying to figure out if there's a way to set the enable and disable for the main form's ToolStripMenuItem. I'm processing UDP packets inside of a thread and when I receive a specific packet I want to allow a previously disabled item to become enabled. I am able to do this with buttons, but I don't know if I can with toolstrip items.

For example, to do what I want with a button from my thread I can use the following line:
this.bSendButton.Invoke(new MethodInvoker(delegate { this.bSendButton.Enabled = true; }));

There is no invoke function associated with the toolstrip item, so that previous way does not work. Is there another way I can do this? Am I trying to do this the completely wrong way? Any input would be helpful.