Asynchrony (computer programming): Difference between revisions

Content deleted Content added
Line 19:
1. '''I/O operations''': I/O operations like file I/O, network I/O, database I/O, (which is generally just network I/O), and web service calls benefit from asynchrony. Anytime that your code is making a database call, or a web service call or a network call or talking to the file system, that can be done asynchronously while that operation is in progress.
 
2. '''Performing multiple operations parallellyin parallel''': When you need to do different operations in parallel, for example, making a database call, web service call and any calculations, then we can use asynchrony.
 
3. '''Long-running event-driven requests:''' This is the idea where you have a request that comes in, and the request goes to sleep for some time waiting for some other event to take place when that event takes place, you want the request to continue and then send a response to client. So in this case, when request comes in, then thread is assigned to that request and as request goes to sleep, then thread is sent back to threadpool and as the task completes, then it generates the event and picks a thread from thread pool for sending response (the thread sent and picked from thread pool might or might not be the same.<ref>{{Cite web|url=https://www.codeproject.com/Tips/866962/Async-and-Await-Tutorial|title=Async and Await Tutorial|last=Goel|first=Gaurav|date=|website=Code Project|url-status=live|archive-url=|archive-date=|access-date=March 3, 2020}}</ref>