Cannot convert anonymous method to type ‘System.Delegate’ because it is not a delegate type

When I tried to build the following code, I got the error in the title.

    this.Invoke(delegate()
    {
        Application.DoEvents();
    });

I can overcome it by converting the anonymous method to a delegate:

    this.Invoke(new Action(delegate() {
        Application.DoEvents();
    }));
   
More to read:

They are Anonymous Methods, not Anonymous Delegates.
http://staceyw.spaces.live.com/blog/cns!F4A38E96E598161E!1042.entry

This entry was posted in dotNET. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>