Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8682373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:45:20+00:00 2026-06-12T21:45:20+00:00

Let say I have an async method: public async Task Do() { await Task.Delay(1000);

  • 0

Let say I have an async method:

public async Task Do()
{
    await Task.Delay(1000);
}

Another method is trying to call Do method inside catch block

public async Task DoMore()
{
    try
    {
    }
    catch (Exception)
    {
        await Do(); //compiled error.
    }
}

But this way, the compiler does not allow using await inside catch, is there any reason behind the scene why we could not use it that way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T21:45:21+00:00Added an answer on June 12, 2026 at 9:45 pm

    Update

    This will be supported in C# 6. It turned out that it wasn’t fundamentally impossible, and the team worked out how to do so without going mad in the implementation 🙂

    Original answer

    I strongly suspect it’s the same reasoning that prevents yield return from being used in a catch block.

    In particular:

    First off, we still have the problem that it is illegal to "goto" into the middle of the handler of a try-protected region. The only way to enter a catch block is via the "non-local goto" that is catching an exception. So once you yielded out of the catch block, the next time MoveNext was called, we’d have no way to get back into the catch block where we left off.

    Second, the exception that was thrown and caught is an intrinsic part of the execution of the catch block because it can be re-thrown using the "empty throw" syntax. We have no way of preserving that state across calls to MoveNext.

    Replace "yield" with "await" there, and I think you’ll have your answer.

    It feels like it would be an odd thing to want to do in most cases, and you should usually be able to rewrite your code fairly easily to await after the catch block – unless you were trying to await something and then throw, of course. In that case it would be a bit of a pain, I admit…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one asynchronous method: public async Task<BitmapSource> GetBitmapAsync(double[] pixels); Let's say I also
I'm trying to do some async stuff in a webservice method. Let say I
Let's say I have an async controller like that below ~ public class HomeController
Let's say you have a Javascript function that calls a web service method. So
Let say i have 15 or more posts in one page. The code inside
Let say I have a simple form with no required fields: <form action=index.jsp method=post>
let say i have following class: class Shape { public int widht; public List<Point>
Let say we have below program: class A { public: virtual fun(){}; }; class
Let's say I have some APM (BeginXxx, EndXxx) pattern async methods (as part of
Let say I have the following data in R. training = factor(c(1,1,3,2,1,3,2,34,67,34)) test =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.