Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: Robust Async Error Handling | Timeouts, Parallelism, and Error Handling
Practice
Projects
Quizzes & Challenges
Quizzer
Challenges
/
C# Async and Await Practice
close
Sektion 3. Kapitel 6
single

single

bookChallenge: Robust Async Error Handling

Stryg for at vise menuen

Opgave

Swipe to start coding

Write a C# console application that demonstrates error handling in async methods.

  • Implement the ThrowingAsyncMethod so that it simulates asynchronous work (such as with Task.Delay) and then throws an exception with the message Error occurred in async method!.
  • In the Main method, call ThrowingAsyncMethod using await inside a try/catch block.
  • When the exception is caught, print the exception message to the console using Console.WriteLine.
  • Ensure your program can be run and the exception message is displayed correctly when the async method fails.

Løsning

Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 3. Kapitel 6
single

single

Spørg AI

expand

Spørg AI

ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

some-alt