Yes, Action<stringis what was meant.
It doesn't matter either way, like you said, but I felt that it wasn't a
bad idea to encapsulate the logic for updating the status. However, if
that's all that needs to be done, then it really doesn't matter.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"Peter Duniho" <Np*********@nnowslpianmk.comwrote in message
news:op***************@petes-computer.local...
On Thu, 05 Jul 2007 07:43:01 -0700, Nicholas Paldino [.NET/C# MVP]
<mv*@spam.guard.caspershouse.comwrote:
[...]
public void ThreadEntryPoint()
{
// Do work here.
// Update the textbox.
statusTextbox.Invoke(new Action<T>(UpdateStatus),
new object[]{ "Updated status." });
}
I think instead of "Action<T>" you meant to write "Action<string>". Right?
Personally, I prefer the anonymous delegate method unless there's a
specific need for the method being invoked to be reused elsewhere (e.g.
it's more complicated than just a single assignment and you do the same
thing from other places in the code):
statusTextbox.Invoke(new MethodInvoker(delegate() { statusTextbox.Text
= "Updated status"; }));
Of course, the string "Updated status" can be replaced by whatever is
suitable in the context, like a variable referring to a string, or the
result of a call to some variable's ToString() method, or whatever.
And of course, either way is fine. There's nothing wrong with using a
non-anonymous delegate method.
Pete