I cant find information about retargeting my code from .NET 4.5 to 4.0. I have to install this application on Windows XP.
my code in .NET 4.5
public async Task <IXLWorksheet> ImportFile(string fileToImport)
return await Task.FromResult<IXLWorksheet>(Sheet1)
You're returning the awaited result of a task, which is constructed on a result. The solution is rather simple - drop the
async keyword in the method declaration will take care of wrapping it in a task.
If, for some reason, you need to manually wrap an existing value in a completed task, you can use
TaskCompletionSource - it's a bit clunkier than
Task.FromResult, but just a bit.