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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:26:14+00:00 2026-06-04T15:26:14+00:00

Just getting my hands on AsyncEnumerator library and not sure what piece I am

  • 0

Just getting my hands on AsyncEnumerator library and not sure what piece I am missing.
I trying to get to run an example provided by the library author himself but have no clue what does the “Execute” in the line:

ae.Execute(ProcessAllAndEachOps(ae, urls));

method refer to.
Can anybody give me some clues?

UPDATE:
I managed to get it running by making a few changes which are already included in the code below. The credit goes to Peter for noticing that the Execute() method of the AsyncEnumerator object is obsolete and should be replaced with some helper function.

using System;
using System.Collections.Generic;
using System.Net;
using Wintellect.Threading.AsyncProgModel;


public static class AsyncEnumeratorPatterns {

    private static void Execute(AsyncEnumerator ae, IEnumerator<Int32> enumerator){
                    ae.EndExecute(ae.BeginExecute(enumerator, null));
    }

      public static void Main() {
        String[] urls = new String[] { 
          "http://Wintellect.com/", 
          "http://1.1.1.1/",   // Demonstrates error recovery
          "http://www.Devscovery.com/" 
        };

        // Demonstrate process
        AsyncEnumerator ae = new AsyncEnumerator();
        Execute(ae, ProcessAllAndEachOps(ae, urls));
      }

      private static IEnumerator<Int32> ProcessAllAndEachOps(
           AsyncEnumerator ae, String[] urls) {
        Int32 numOps = urls.Length;

        // Issue all the asynchronous operation(s) so they run concurrently
        for (Int32 n = 0; n < numOps; n++) {
          WebRequest wr = WebRequest.Create(urls[n]);
          wr.BeginGetResponse(ae.End(), wr);
        }

        // Have AsyncEnumerator wait until ALL operations complete
        yield return numOps;

        Console.WriteLine("All the operations completed:");
        for (Int32 n = 0; n < numOps; n++) {
          ProcessCompletedWebRequest(ae.DequeueAsyncResult());
        }

        Console.WriteLine(); // *** Blank line between demos ***

        // Issue all the asynchronous operation(s) so they run concurrently
        for (Int32 n = 0; n < numOps; n++) {
          WebRequest wr = WebRequest.Create(urls[n]);
          wr.BeginGetResponse(ae.End(), wr);
        }

        for (Int32 n = 0; n < numOps; n++) {
          // Have AsyncEnumerator wait until EACH operation completes
          yield return 1;

          Console.WriteLine("An operation completed:");
          ProcessCompletedWebRequest(ae.DequeueAsyncResult());
        }
      }

      private static void ProcessCompletedWebRequest(IAsyncResult ar) {
        WebRequest wr = (WebRequest)ar.AsyncState;
        try {
          Console.Write("   Uri=" + wr.RequestUri + "    ");
          using (WebResponse response = wr.EndGetResponse(ar)) {
            Console.WriteLine("ContentLength=" + response.ContentLength);
          }
        }
        catch (WebException e) {
          Console.WriteLine("WebException=" + e.Message);
        }
    }
}
  • 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-04T15:26:16+00:00Added an answer on June 4, 2026 at 3:26 pm

    As others have stated, the Execute method was deprecated a while ago and is now gone completely, that MSDN example is quite old.

    That method slightly defeated the point of the AsyncEnumerator class, as the thread making the call will run the iterator until the first yield and then block until the iterator has finished processing.

    So its maybe more clear to replace it with:

    var asyncResult = ae.BeginExecute(ProcessAllAndEachOps(ae, urls), null);
    asyncResult.AsyncWaitHandle.WaitOne();
    ae.EndExecute(asyncResult);
    

    Which looks a little bit more like making regular APM calls from within an AsyncEnumerator iterator and makes the blocking more explicit.

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

Sidebar

Related Questions

I was just getting ready to get my hands rough with Nodejs, but while
I just tried to run the NAudio demos and I'm getting a weird error:
I'm just getting my hands on Django Managers and I've found myself doing this
I'm just getting my hands dirty with class-based views. What is the correct way
Just trying to write a function that gets clock hand angles, but getting an
Just getting my hands around intent filters, and I've noticed a rather hit and
I'm trying to get the ADT working in Eclipse, but I'm getting random hangs
I'm just getting acquainted with Vim's CTags functionality - and it's damn handy. One
Just getting started with C++ here. I am working on OSX with Eclipse CDT.
Just getting started with db2. Quick question about giving it SQL commands from 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.