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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:30:43+00:00 2026-05-27T10:30:43+00:00

A few related questions about the async CTP: I can iterate over an Iterator

  • 0

A few related questions about the async CTP:

  • I can iterate over an Iterator Block (an IEnumerable<T> yield-returning T) using GetEnumerator() and then enumerator methods MoveNext(), and Current(). What is the analog for async methods? How can a non-async calling method to receive and process any awaited items and then ContinueWith()? Can you provide a short example? I’m just not seeing it.

  • Also, in this following example async method, MyAwaitable has a GetAwaiter() method. If GetAwaiter() returns a string but THuh is not string, the compiler doesn’t complain. What type constraints/expectations exist between THuh and GetAwaiter()?

    async Task<THuh> DoSomething()
    {
         var x = await new MyAwaitable("Foo");
    
         var y = await new MyAwaitable("Bar");
    
         return null;
    } 
    
  • Please explain the following line of the C# spec draft. Are async Task<T> methods supposed to return a default(T) which will never be used? I see some samples that do not seem to follow this rule – the return value seems reachable and the value is non-default. Is this value inaccessible? If so, why the awkward inaccessible return statement?

In an asynchronous function with the return type Task<T> for some T,
return statements must have an expression that is implicitly
convertible to T, and the endpoint of the body must be unreachable.

  • The spec says “All of GetAwaiter, IsCompleted, OnCompleted and GetResult are intended to be “non-blocking”” – so then in what method should the (potentially) long-running operation be defined?

Thanks!

  • 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-27T10:30:44+00:00Added an answer on May 27, 2026 at 10:30 am

    I’m trying to convert continuation-passing I did (awkardly but successfully) with Iterator Blocks and converting it to use async instead. I think I’m fighting the new way. Understanding the change feels like tearing apart 3-inch wide strips of Velcro.

    I can understand how you might feel that way. I discourage people from trying to build CPS out of iterator blocks because really it is not a good fit, no matter what underlying mechanisms iterators and CPS have in common. Iterator blocks are designed to feel good for quickly making methods that turn data structures into sequences or turn sequences into different sequences; they’re not designed to solve the general problem of call-with-current-continuation.

    For that matter, async/await isn’t precisely call-with-current-continuation either, though it comes an order of magnitude closer, obviously. Async/await is designed to make task-based asynchrony easier; that it does so by rewriting code into a form of continuation passing style is an implementation detail.

    This answer I wrote on a related topic might help:

    How could the new async feature in c# 5.0 be implemented with call/cc?

    I suspect that the conceptual problem that you’re having is that in iterator-style asynchrony, the “orchestrator” — the thing figuring out when the iterator block gets to resume where it left off — is your code. You write some code and you decide when to call MoveNext to pump the iterator. With task-based asynchrony, some other hunk of code does that for you. When a task completes, odds are good that it posts that fact to a message queue somewhere, and then when the message queue is pumped, the continuation gets activated with the result. There’s no explicit “MoveNext” in your code that you can point at; rather, the fact that a task has completed and knows its own continuation is sufficient to ensure that the continuation is put onto a work queue for eventual execution.

    If you’ve got more questions, I encourage you to post them on SO and/or the async forum.

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

Sidebar

Related Questions

I have a few questions about endian-ness that are related enough that I warrant
I have a few related questions about managing aligned memory blocks. Cross-platform answers would
I have a few questions related: 1) Is possible to make my program change
I have a few questions related to Windows processes in kernel and usermode. If
I've seen a few questions related to API specifics and paypal. Generally speaking if
I've got a few questions related to the use of MonoRail Testing Does everyone
Ok, I've asked a few related questions here and only ended up with more
I am studying for a final and have a few questions about RMI and
I found a few questions related to this around here but not exactly what
I have a few questions about data synchronization. The architecture does not seem to

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.