What if your app could keep working smoothly while waiting for slow tasks to finish?
Why Returning values from async methods in C Sharp (C#)? - Purpose & Use Cases
Imagine you are waiting for a friend to bring you a book, but instead of just asking them to bring it, you keep checking every minute if they have arrived. You waste time and energy waiting without doing anything else.
Manually waiting for a task to finish blocks your program from doing other useful work. It's slow and can cause your app to freeze or become unresponsive, frustrating users and making your code messy.
Returning values from async methods lets your program ask for data and continue working while waiting. When the data is ready, it comes back automatically, keeping your app smooth and efficient.
var result = LongRunningTask().Result; // blocks until done
var result = await LongRunningTask(); // continues without blocking
You can write programs that stay fast and responsive even when waiting for slow tasks like downloading files or fetching data.
When a weather app asks the internet for the latest forecast, it uses async methods to get the data without freezing the screen, so you can still scroll or check other info.
Manual waiting blocks your program and wastes time.
Async methods return values without stopping your app.
This keeps programs responsive and user-friendly.