The idomatic way to start a new side-effect-only task (that is: a task that returns no result) using the TPL in .NET 4.0 is using the following API:
Task Task.Factory.StartNew(Action<object>, object)
But why doesn't the signature of this API look like this
Task Task.Factory.StartNew<T>(Action<T>, T)
or like this
Task Task.Factory.StartNew<T>(T, Action<T>)
Technical reasons or some other reason?
Okay, now that I understand the question properly :)
I believe it's because this is meant to be a direct replacement for
ThreadPool.QueueUserWorkItem
. I do agree that it seems somewhat odd... but if you're using lambda expressions anyway, it's probably easier to use the version that does take a state parameter (i.e.Action
instead ofAction<object>
) and just capture the value you're interested in beforehand. It doesn't help if you're specifying the value and the function separately :(