Just in case I'm the only person that didn't know this, you can't pass an anonymous method as an argument to Control.Invoke() when you're trying to make cross-thread calls. Instead, you have to wrap it in a Delegate like the MethodInvoker delegate like this code below:
23 public string CurrentActivity
24 {
25 get { return _activityStrip.Text; }
26 set
27 {
28 if (InvokeRequired)
29 {
30 MethodInvoker invoker = new MethodInvoker(delegate()
31 {
32 _activityStrip.Text = value;
33 });
34 Invoke(invoker);
35 }
36 else
37 {
38 _activityStrip.Text = value;
39 }
40 }
41 }
It's fine and it works, but it's butt ugly. I'm mildly tempted to try out Boo for this very reason or maybe play with RubyCLR to drive WinForms with a cleaner syntax.
Posted
Sun, Nov 5 2006 8:49 PM
by
Jeremy D. Miller