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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:24:06+00:00 2026-05-31T22:24:06+00:00

C# has a cool new feature public Task<string> async f() { string r =

  • 0

C# has a cool new feature

public Task<string> async f()
{
    string r = LongCompute();
    return r;
}

but isn’t that equivalent to

public Future<String> f() {
    return Globals.executorService.submit(new Callable<String>() {
        public String call() throws Exception {
            String r = longCompute();
            return r;
        }
    });
}

where in Java you have more flexibility to choose the threadpool in which the task would run.

What about await? It’s equivalent to just calling get

string s = await f();

is just like

String s = f().get();

Is there anything more to C#, or is it indeed just a syntactic sugar to the Java version? (I’m not a C# guru, so I might be missing something).

  • 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-05-31T22:24:08+00:00Added an answer on May 31, 2026 at 10:24 pm

    No, await is not like just calling get(). There’s considerably more to it.

    When you use an await expression in C#, the compiler effectively creates a continuation, so that if the awaitable hasn’t completed yet, the method can immediately return, and continue processing only when it’s completed. The continuation will run in an appropriate context – so if you’re on a UI thread before the await expression, you’ll continue on the UI thread afterwards, but without blocking the UI thread while you’re waiting for the result. For example:

    public async void HandleButtonClick(object sender, EventArgs e)
    {
        // All of this method will run in the UI thread, which it needs
        // to as it touches the UI... however, it won't block when it does
        // the web operation.
    
        string url = urlTextBox.Text;
        WebClient client = new WebClient();
        string webText = await client.DownloadStringTaskAsync(url);
    
        // Continuation... automatically called in the UI thread, with appropriate
        // context (local variables etc) which we used earlier.
        sizeTextBox.Text = string.Format("{0}: {1}", url, webText.Length); 
    }
    

    Ultimately it’s all syntactic sugar, but much more complicated sugar than what you’ve shown.

    There’s a lot of detailed information available on the web already. For example:

    • Eric Lippert’s blog
    • The Microsoft C# async/await guide
    • My own blog posts about async
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Visual Studio 2010 has a new feature that is just way cool. You can
Recenty I installed ReSharper 4.5. It has a cool new feature of checking naming
Quicksearch is really cool... but it has a usability issue that makes it behave
Clang has new feature called ARC. Concept looks cool. Is this feature support detecting
I understand that the new TPL (Task Parallel Library) has implemented the Parallel.ForEach such
I'm wondering about that many new applications, I think most built in WPF, has
I'm very new to JQuery, but I was told the one of the cool
I'm new to RoR and started making a project recently. The project has public/stylesheets
I installed Xcode 4, it has very cool features. I developed my new app
Say someone has an idea for a new, very useful and cool method, for

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.