Wednesday, January 06, 2010

Anonymous Methods for Control.Invoke

I found a blog post about something I've been trying to do forever: use anonymous methods to get around InvokeRequired issues with C# Form Controls.

Answer, cast delegate with MethodInvoker, ala:
this.Invoke(
(MethodInvoker) delegate { this.Text = "x"; }
);

Thanks Guy Mahieu!