Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте 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

Завдання

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.

Рішення

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 2
single

single

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

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 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.

Рішення

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 2
single

single

some-alt