D
_DD
In the switch-over to C# 2.0, I thought it would be good to get rid of
external delegates for thread access to controls. In looking into
anonymous methods I ran across MethodInvoker. I haven't been able to
come up with code samples that show usage in this context.
Current C# v1 code:
public delegate void ControlUpdateDelegate(long number);
private void ControlUpdater(long number)
{
if (CountTextBox.InvokeRequired) {
this.BeginInvoke(new
ControlUpdateDelegate(ControlUpdater),
number);
} else {
CountTextBox.Text = number.ToString();
}
}
What is the preferred way to do this in C# v2? Does MethodInvoker fit
into the picture, or was that mis-cue?
external delegates for thread access to controls. In looking into
anonymous methods I ran across MethodInvoker. I haven't been able to
come up with code samples that show usage in this context.
Current C# v1 code:
public delegate void ControlUpdateDelegate(long number);
private void ControlUpdater(long number)
{
if (CountTextBox.InvokeRequired) {
this.BeginInvoke(new
ControlUpdateDelegate(ControlUpdater),
number);
} else {
CountTextBox.Text = number.ToString();
}
}
What is the preferred way to do this in C# v2? Does MethodInvoker fit
into the picture, or was that mis-cue?