Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Convert Synchronous Method to Async | Async/Await Fundamentals and Converting Sync to Async
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
C# Async and Await Practice

bookChallenge: Convert Synchronous Method to Async

Task

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.

Solution

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 1. ChapterΒ 2
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

Suggested prompts:

Can you explain this in simpler terms?

What are the main benefits or drawbacks?

Can you give me a real-world example?

close

bookChallenge: Convert Synchronous Method to Async

Swipe to show menu

Task

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.

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 1. ChapterΒ 2
single

single

some-alt