Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use async/await in webmethod asmx service [duplicate]

I am trying to figured it out, but have no success for now. Is it possible to use async/await in webmethod asmx service ? What I found till now is that async/await can be used only in WCF service method (rest or whatever).

like image 575
Nikola Yankov Avatar asked Jun 26 '12 16:06

Nikola Yankov


People also ask

Is async-await on the same thread?

The async and await keywords don't cause additional threads to be created. Async methods don't require multithreading because an async method doesn't run on its own thread. The method runs on the current synchronization context and uses time on the thread only when the method is active.

What is one benefit of using async-await?

The biggest advantage of using async and await is, it is very simple and the asynchronous method looks very similar to a normal synchronous methods. It does not change programming structure like the old models (APM and EAP) and the resultant asynchronous method look similar to synchronous methods.

Does async-await make it synchronous?

Async/await helps you write synchronous-looking JavaScript code that works asynchronously. Await is in an async function to ensure that all promises that are returned in the function are synchronized. With async/await, there's no use of callbacks.

Does async-await improve performance?

C# Language Async-Await Async/await will only improve performance if it allows the machine to do additional work.


1 Answers

This is a bad idea. You're basically trying to use a modern language feature with a legacy technology - when .asmx was introduced the notion of asynchronous services wasn't really established.

An answer may lie here though:

Is there some way to handle async/await behind an ASMX service?

I'd say stick to WCF or WebAPI.

like image 180
KnowHoper Avatar answered Nov 05 '22 11:11

KnowHoper