Well, I am writing a file of extensions / methods useful for strings, labels, links, classes, etc.
but i have a problem. I have a showMessage()
method that changes the label text, works fine. But I decided to do this while working 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 , that was a typo. I typed this code in the forum. the error continues.
according to the documentation , to use the Invoke method, you must import:
Namespace: System.Windows.Forms
Build: System.Windows.Forms (in System.Windows.Forms.dll)
then I did:
using System.Windows.Forms;
but this returns the same error:
The name 'Invoke' does not exist in the current context
How can I fix it?
Thanks in advance.
The mask
source share