I have synchronous code and I'm integrating with library that has only asynchronous methods.
What would be the best way to call asynchronous code from synchronous code and why:
I have two candidates:
Solution A:
var result = _service.CallAsync().GetAwaiter().GetResult()
Solution B:
Task<string> task = Task.Run<string>(async () => await _service.CallAsync().ConfigureAwait(false));
var result = task.Result
Which one is better and is ConfigureAwait(false)
in solution B needed?