Quick way to call Invoke

26 September 2008

The invoke method does not accept anonymous delegates, which makes the code below not compile

Invoke(delegate() { HelloTextbox.Text = "Hello World!"; });

However, the invoke method does accept MethodInvoker delegates, so you can cast an anonymous delegate to MethodInvoker like the code below

Invoke((MethodInvoker)delegate() { HelloTextbox.Text = "Hello World!"; });
 | Posted by admin | Categories: Uncategorized |