Calling an async method from a synchronous method

Task<TResult>.Result (or Task.Wait() when there’s no result) is similar to await, but is a synchronous operation. You should change GetData1() to use this. Here’s the portion to change:

Task<Data> dataTask = Task.WhenAny(runningTasks).Result;
runningTasks.Remove(dataTask);
myData = gameTask.Result;

Leave a Comment