The C# compiler was enhanced in VS2012 to be smarter about generic overload resolution in the presence of async
lambdas (i.e., Func<Task>
and family). Since you're on VS2010, you'll have to help it out here and there.
The clue is in the type of your async
lambda as displayed in your error message: System.Func<System.Threading.Tasks.Task>
.
What it should be is System.Func<System.Threading.Tasks.Task<System.String>>
.
So I would try this:
return TaskEx.RunEx<string> //****** Task.Run --> TaskEx.RunEx (TaskEx.Run)
(async () =>
{
content = await new WebClient().DownloadStringTaskAsync(address);
cachedDownloads.TryAdd(address, content);
return content;//*****Error
});