Acquiring a value via an async method:
var result = Task.Run(() => asyncGetValue()).Result;
Syncronously calling an async method
Task.Run( () => asyncMethod()).Wait();
No deadlock issues will occur due to the use of Task.Run.
More Related Contents:
- await vs Task.Wait – Deadlock?
- An async/await example that causes a deadlock
- When correctly use Task.Run and when just async-await
- Await on a completed task same as task.Result?
- How to safely call an async method in C# without await
- How can I call an async method in Main?
- Difference between await and ContinueWith
- What is the use for Task.FromResult in C#
- Asynchronous Task.WhenAll with timeout
- async Task vs async void
- Waiting for async/await inside a task
- How can I prevent synchronous continuations on a Task?
- Why use async and return await, when you can return Task directly?
- Should I worry about “This async method lacks ‘await’ operators and will run synchronously” warning
- How to convert a Task to a Task?
- Await vs Task.Result in an Async Method [duplicate]
- How can I run both of these methods ‘at the same time’ in .NET 4.5?
- Catch an exception thrown by an async void method
- Is Task.Result the same as .GetAwaiter.GetResult()?
- Have a set of Tasks with only X running at a time
- Does MSTest have an equivalent to NUnit’s TestCase?
- A reusable pattern to convert event into task
- Why would I bother to use Task.ConfigureAwait(continueOnCapturedContext: false);
- The ‘await’ operator can only be used within an async lambda expression
- Correct way to get the CoreDispatcher in a Windows Store app
- Async action filter in MVC 4
- How do you test private methods with NUnit?
- Async provider in .NET Core DI
- How to throttle multiple asynchronous tasks?
- How to get efficient Sql Server deadlock handling in C# with ADO?