If you have a C++ background, I'd describe delegates as simple pointers to functions. Delegates are .NET's way of safely handling function pointers.
To used a named delegate, you first have to create a function to handle the event:
void MyHandler(object sender, EventArgs e)
{
//Do what you want here
}
Then, for your previous code, change it to this:
this.Invoke(new EventHandler(MyHandler), this, EventArgs.Empty);
If I were doing this though, I'd write it like this to avoid duplicate code.
EventHandler handler = (sender, e) => myTextBox.Test = stringData;
if (this.InvokeRequired)
{
this.Invoke(handler, this, EventArgs.Empty); //Invoke the handler on the UI thread
}
else
{
handler(this, EventArgs.Empty); //Invoke the handler on this thread, since we're already on the UI thread.
}