Task.WhenAny for first completion
📖 Scenario: You are building a simple program that runs multiple tasks and wants to know which one finishes first.
🎯 Goal: Create three tasks that complete after different delays, then use Task.WhenAny to find and display the first task that finishes.
📋 What You'll Learn
Create three tasks with different delays
Use a variable to hold the first completed task
Use
Task.WhenAny to get the first completed taskPrint which task finished first
💡 Why This Matters
🌍 Real World
In real apps, you might start multiple operations and want to react as soon as one finishes, like loading data from multiple sources and using the fastest response.
💼 Career
Understanding Task.WhenAny is important for asynchronous programming in C#, which is common in web, desktop, and mobile app development.
Progress0 / 4 steps