I have a class in which constructor I need to use one async method. The problem is that in a constructor I can use the async keyword so I can't use the await with async method. So by the moment I am using this way:
Task myTask = Task.Run(() =>
{
myList.AddRange(MymethodAsync().Result.OrderBy(x => x.Name));
});
But I don't know if it is the best way, wrap the method in a task.
I have tried this:
myList.AddRange(MymethodAsync().Result.OrderBy(x => x.Name));
But this block my application, it is a problem with Result.
Really I need to use in the constructor various async methods, that if I could, I would like to run in parallel and wait until all of them have finished.
Thanks.