Lambda expression are not implicitly convertible to delegates in certain cases. Specifically, if the method expects the type Delegate
you have to first explicitly cast the lambda for the compiler to accept it.
What you can do is explicitly cast the lambda, which should allow you to use BeginInvoke
:
lvMyAssignments.Dispatcher.BeginInvoke( (Action)(() =>
{
lvMyAssignments.ItemsSource = e.HandOverDocs;
}));
Normally, if you have a method with a strongly-typed delegate signature, like:
public static void BeginInvoke( Action d ) { ... }
The compiler can convert a lambda expression to the appropriate delegate signature needed. But if the method is loosely typed:
public static void BeginInvoke( Delegate d ) { ... }
the compiler will not accept a lambda. You can, however, cast the lambda expression to a specific delegate signature (say Action), and then pass that to the method. The compiler cannot automatically do this for you, because there are many different delegate types that could be a valid match for the signature of the lambda ... and the compiler has no way of knowing which would be the right one.