Well, I'm writing a file of extensions/method useful to strings,label,linklabels,class etc.
but, I have a problem. I have an showMessage()
method that change the Text of label, works fine. But I decide to do that works with thread execution, then I do this:
namespace LabelExtensions
{
public static class LabelExtensionsClass
{
private delegate void UpdateState();
public static void ShowMessage(this Label label, string text)
{
if (label.InvokeRequired)
{
label.Invoke((UpdateState)delegate
{
label.Text = text;
});
}
else
{
label.Text = text;
}
}
}
}
sorry, it was a typo. I typed this code on forum. the error continue.
according the documentation,to use the Invoke method need to imports:
Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
then I did:
using System.Windows.Forms;
but this returns same error:
The name 'Invoke' does not exist in the current context
how I fix this?
Thanks in advance.
Action
delegate; you don't need to create your own. – Caponize(label.TopLevelControl as Form).Invoke
– Ganges