Which of these two methods are better to update the UI from another thread? (for me they work both, but which is safer?) I would prefer the SetPropertyThreadSafe method as it needs less code.
1.
label1.SetPropertyThreadSafe(() => this.label1.Text, "New Value");
2.
if (label1.InvokeRequired)
{
label1.Invoke(new MethodInvoker(delegate {
label1.Text="New Value"; }));
}
SetPropertyThreadSafe
is not a method built in to .NET, if you are using this implmentationThen the two examples you posted are doing the exact same thing so there is no difference.