Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre Challenge: Convert Synchronous Method to Async | Async/Await Fundamentals and Converting Sync to Async
C# Async and Await Practice
Section 1. Chapitre 2
single

single

bookChallenge: Convert Synchronous Method to Async

Glissez pour afficher le menu

Tâche

Glissez pour commencer à coder

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.

Solution

Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 1. Chapitre 2
single

single

Demandez à l'IA

expand

Demandez à l'IA

ChatGPT

Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion

some-alt