You can only convert from lambda expressions to specific delegate types. In this particular case it's really easy though - you can just use Action
instead (or MethodInvoker
, or any delegate type with no parameters and a void
return type):
if (this.InvokeRequired)
{
this.Invoke((Action) (() => this.CheckVersionInfo()));
}
Or just use a method group conversion to simplify things:
if (this.InvokeRequired)
{
this.Invoke((Action)CheckVersionInfo);
}
Alternatively, add an extension method to Control
or ISynchronizeInvoke
either just to add an Invoke(Action)
method, or a "check and invoke" method. (Both can be useful, in different contexts.)
To be honest though, I would be very nervous of the rest of the code you're importing if it's basically broken like this. If the code doesn't even compile to start with, how much confidence do you have that it will work once you've fixed the most obvious errors?
Note that this isn't just a matter of different versions of C# or anything like that - the code you've posted would never have worked, in any version of C#.