Considering the following code:
public void CacheData()
{
Task.Run((Action)CacheExternalData);
Task.Run(() => CacheExternalData());
Task.Run(CacheExternalDataTask);
Task.Run(CacheExternalData);
}
public Task CacheExternalDataTask()
{
// Long running code
return Task.FromResult("Data");
}
public void CacheExternalData()
{
// Long running code
}
Why is Task.Run(CacheExternalData)
ambiguous? And Task.Run(CacheExternalDataTask)
is not?
When calling Task.Run
with CacheExternalData
I would have thought it was clear to the compiler that the method does not return a Task
and it should resolve to an Action
?