Challenge: Convert Synchronous Method to Async
Oppgave
Swipe to start coding
Refactor the provided synchronous DownloadFile method so that it becomes asynchronous using async and await. The current version blocks the thread for 3 seconds to simulate a file download.
- Modify the method so that it does not block the calling thread.
- Replace the blocking call with an asynchronous alternative that simulates a 3-second delay.
- Ensure the method uses the correct async method signature and is called appropriately from
Main.
Løsning
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 1. Kapittel 2
single
Spør AI
Spør AI
Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår
Suggested prompts:
Can you explain this in simpler terms?
What are the main benefits or drawbacks?
Can you give me a real-world example?
Fantastisk!
Completion rate forbedret til 5.56
Challenge: Convert Synchronous Method to Async
Sveip for å vise menyen
Oppgave
Swipe to start coding
Refactor the provided synchronous DownloadFile method so that it becomes asynchronous using async and await. The current version blocks the thread for 3 seconds to simulate a file download.
- Modify the method so that it does not block the calling thread.
- Replace the blocking call with an asynchronous alternative that simulates a 3-second delay.
- Ensure the method uses the correct async method signature and is called appropriately from
Main.
Løsning
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 1. Kapittel 2
single