Hi I see following code:
void UpdateMessage (string message)
{
Action action = () => txtMessage.Text = message;
this.Invoke (action);
}
Why using Action and then invoke action here? Why not just using txtMessage.Text = message
to replace the code in function body?
Update
A fuller version of the code, presented in a comment, reproduced below with syntax highlighting, indentation etc.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
new Thread(Work).Start();
}
void Work()
{
Thread.Sleep(5000);
UpdateMessage("My Garden");
}
void UpdateMessage(string message) {
Action action = () => textBox1.Text = message;
this.Invoke(action);
}
}