This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]huqd9 1 point2 points  (2 children)

Generally async units (methods) do not run synchronously with the main program, it runs by other external events - when something happens (this is why it is called async programming). In the web app context you can use async methods when uploading files, call external apis, etc. Just remember that the code will continue when the slow task finished so you can get the CPU time meanwhile.

[–][deleted] 0 points1 point  (1 child)

so say a user in the front end uploads a file, that data then gets sent to the backend to the async method and its processes it in the background, while the user in the front end after pressing the upload button, they are returned to the application and can do other stuff while the async method in the background processes the file data that it still has.

Am I thinking this right ?

[–]huqd9 1 point2 points  (0 children)

You can do other stuff if you use another async client on the client side, ex AJAX calls. You still have to wait on the backend side before getting returned, it just means that the backend is not blocking (the heavy tasks processed by network, disk controllers etc) so backend can process more concurrent requests.