Missing syncronous methods for dotnet core?
See original GitHub issueThis might be a stupid question, but after adding version 7.2.1
to my dotnet core 1.1 netstandard 1.6.1 project there are only async methods available even though all “getting started” guides clearly contains syncronous versions of the methods.
Am I missing here or have they not been implemented yet for dotnet core?
Best regards
Håkan
Issue Analytics
- State:
- Created 7 years ago
- Reactions:9
- Comments:29 (6 by maintainers)
Top Results From Across the Web
Finding Async Method Calls Missing Await - NET Core Tutorials
In recent versions of .NET and Visual Studio, there is now a warning that will show to tell you your async method is...
Read more >WCFclient operation only Async .Net core 2.0
Your client does not expose synchronous method but that shouldn't be a problem for you. Instead of asynchronously calling the method just do ......
Read more >> What I want to know is, will the sync (not async/await) ...
What I want to know is, will the sync (not async/await) methods be available on Linux on .NET Core? Yes, they most likely...
Read more >Don't get burned by missing await Calls for Async Code in ...
The moral of this story is this: Make sure your Async methods are actually called asynchronously especially if it deals with ASP.NET Core...
Read more >Breaking changes in .NET Core 3.0
NET Core 1.0 APIs have been replaced by extension methods in ... NET Core 3.0, synchronous server operations are disabled by default.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @TechInceptions , @tidyui Can you clarify for us what your need is for the synchronous methods? Overall, sync is much less resource efficient than async and is not something that we recommend to our customers. You can always use
.GetAwaiter.GetResult()
if you need to block on the async calls.We have had some conversations with the CLR team, who provided this guidance:
.NET Core team has chosen to not support a true sync api for the reasons listed above (resource consumption, etc.) Even if we implement a true sync, it would end up being sync over async at some level. For this reason, we believe that adding fake sync apis would be a hindrance and not a help to our customers. Please let us know if you have any feedback regarding this.
You should support true sync because millions of operations, as coded in people’s libraries, ARE synchronous (for all kinds of reasons).
Regarding synchronicity, Ideally, APIs should have two paths: True Sync, and True Async.
In the .NET world, “sync over async” is filled with anxiety - one never knows how it’s going to turnout. Taking your library as an example, when you yanked the sync methods from the API surface, the 1st “patch” implementations will most likely be “sync over async”.
Regarding the “.GetAwaiter.GetResult()” work around, is it more reliable that “Task.Run (()=> … )” ?
I suspect “.GetAwaiter.GetResult()” will lead to deadlocks in UI chained scenarios.
I have heard that argument before and I don’t buy it. Isn’t it better that the people with a better understanding of their own codebase do the tricky work of ensuring that something like “sync over async” works?
Mark my words, as we try to create a “better .NET” by forcing async, we are actually creating a “worse .NET” by generating “sync over async” as a direct consequence.