You are trying to delegate a variable in a method call. Just deleting a variable declaration can be wonderful:
public static void Main(string[] args) { Task.Factory.StartNew(() => Console.WriteLine("etc.")); }
Here, the Action not derived from the lambda expression itself, but from the method that it is trying to do. Normal overload resolution is performed, and the compiler tries to convert the lambda expression to the appropriate parameter type. If the parameter type was just Delegate (e.g. Control.Invoke ) then the output type failed because the compiler would not have any specific target types to try to convert.
If this does not work (I cannot easily check its atm), you just need to specify to indicate which type of delegate the lambda expression should be converted:
public static void Main(string[] args) { Task.Factory.StartNew((Action)(() => Console.WriteLine("etc."))); }
Honestly, at this point I would prefer to see a separate variable in terms of readability.
Jon skeet
source share