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

  • Home
  • SEARCH
  • 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 5986835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:43:45+00:00 2026-05-22T22:43:45+00:00

I am playing with the new Async CTP bits, and I can’t get it

  • 0

I am playing with the new Async CTP bits, and I can’t get it work with either server-side or just command-line program (and all the examples are either WPF or Silverlight). For example, some trivial code like:

class Program {
    static void Main() {
        Program p = new Program();
        var s = p.Ten2SevenAsync();
        Console.WriteLine(s);
    }

    private async Task<int> Ten2SevenAsync() {
        await TaskEx.Delay(10000);
        return 7;
    }
}

returns immediately and prints System.Threading.Tasks.Task1[System.Int32]` instead of waiting for 10 secs and return 7 (as I would expect). Must be something obvious that I am missing.

  • 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-22T22:43:46+00:00Added an answer on May 22, 2026 at 10:43 pm

    The whole point of the await-based code is that it is indeed “execute the next stuff when this is finished” (a callback), and not “block the current thread until this has finished”.

    As such, from Ten2SevenAsync you get back a task, but that task is not yet complete. Writing the task to the console does not mean it waits for it to complete. If you want to block on the task’s completion:

    static void Main() {
        Program p = new Program();
        var s = p.Ten2SevenAsync();
        Console.WriteLine(s.Result);
    }
    

    or more explicitly:

    static void Main() {
        Program p = new Program();
        var s = p.Ten2SevenAsync();
        s.Wait();
        Console.WriteLine(s.Result);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm playing with the new geography column in SQL Server 2008 and the STGeomFromText
So I'm kind of new to VB and am just playing around with a
I'm playing with a new service's very simple API and I'm just curious if
Extremely new to Java an just playing around with it. I'm trying to add
I am playing with HttpListener and Async CTP class HttpServer : IDisposable { HttpListener
i was playing around on our dev server for a while for a new
Playing with the new(ish) url rewriting functionality for web forms, but I'm running into
I am playing with the new stuff of C#3.0 and I have this code
I'm new to ruby and I'm playing around with the IRB. I found that
I'm playing a little bit with the new StackOverflow API . Unfortunately, my JSON

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.