To fix the issue you can do Assuming that //...Calls to get and build up IList is synchronous CPU bound work, the issue there is that GetStuffViaLongRunningTask won't return until it either ends, or hits its first await call. You should be getting a compiler warning on that method as it's an async method that doesn't have an await in it. Instead, the method simply shouldn't be async, to clearly indicate to it's callers that it's synchronous work. Just adjust the signature to:
Any of those help I have read that async/await methods runs in the same thread as caller and I saw it in a WPF application but while testing a code in console application I see it is running in a different thread than caller. Have I missed something? , Have I missed something?
Node.JS non blocking IO and other frameworks like ASP.NET MVC not-blocking io via async/await
I wish did fix the issue. At a high level, they are equivalent, with one major difference. In Node, all requests are handled on the same thread; whereas in ASP.NET, all requests are handled by the thread pool. Node is a single-threaded asynchronous approach, while ASP.NET is a multi-threaded asynchronous (or synchronous) approach. For this reason, Node cannot handle synchronous APIs at all, and if there is an API that should be asynchronous but isn't, Node will pretend it's asynchronous by pushing it onto a thread pool thread so that the main thread can continue handling other requests.
like below fixes the issue This getId().Result; is a blocking call that possibly would result in a deadlock scenario. The current thread of execution would block until the function that is called to return. On the other hand using the async/await approach you will not block. The thread that process this call, would stop and would be available for processing another call. Then when your function call would be completed, the result would be processed by another thread of the thread pool.