Are there alternate ways to input a parameter(s) into a task besides using lambda functions?
It seems like Task.Run(DoSomethingElse(myInput));
should work since Task.Run(DoSomething);
works but clearly it does not.
Using a lambda function only to convert a function with parameters to one without parameters seems odd, like an awkward cast. Task.Run(() => DoSomethingElse(myInput));
Main()
{
object myInput = new();
Task.Run(DoSomething); // Happy Code
Task.Run(() => DoSomethingElse(myInput)); // Happy Code
Task.Run(DoSomethingElse(myInput)); // CS1503 Argument 1: cannot convert from 'System.Threading.Tasks.Task' to 'SystemAction'
}
Task DoSomething()
{
// Something
}
Task DoSomethingElse(object input)
{
// Something else
}