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 8385611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:42:56+00:00 2026-06-09T17:42:56+00:00

If an async method declared with async has a return type of Task or

  • 0

If an async method declared with async has a return type of Task or Task<TResult> it can be awaited. Inside the method no task is returned in C# code, but in case of Task<TResult> a value of TResult. For instance:

private static async Task<int> AsyncDemo()
{
    await Task.Delay(1000);
    return 1;
}

The resulting IL code returns the task of the AsyncTaskMethodBuilder that started the compiled state machine. My question is what this task actually represents. I assume it’s a task that represents not a thread or so, but the execution of the state machine. I assume also that the task is completed when the state machine is finished or set to the Faulted state when an Exception occurs. I appreciate clarification.

  • 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-09T17:42:58+00:00Added an answer on June 9, 2026 at 5:42 pm

    The task conceptually represents the method.

    When the method returns, the task is completed (successfully), with the result set to the value returned by the method (if applicable). If the method throws an exception, the task is faulted (completed with an error). There’s a special case for OperationCanceledException: in that case, the task is canceled (completed with cancellation).

    Technically, the task does represent the state machine, which is a rewriting of the method. But since the state machine is hidden, the task conceptually represents the method itself.

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

Sidebar

Related Questions

I have some async method public static Task<JObject> GetUser(NameValueCollection parameters) { return CallMethodApi(users.get, parameters,
I want a method like this: public async void DoSomething() { DoSomethingElse(); } But
I have an Async method returning a Task. I also wish to offer a
How to wrap existing async method that accepts callback function as parameter into Task
When writing async method implementations using the BeginInvoke/EndInvoke pattern the code might look something
Is it bad to have expensive code at the start of an async method,
Given the following method: public async Task<MyObject> DoSomethingAsync() { // do some work await
I have a piece of code (on a server) that uses async method to
I am calling a async method having a single parameter, It will return me
In my WCF service contract I have declared an asyn method that return a

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.