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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:47:50+00:00 2026-06-04T10:47:50+00:00

I call an async method which in turn calls needs to start several async

  • 0

I call an async method which in turn calls needs to start several async opertions.

Once all the async operations are finished, I need need notify the caller whether the operations were completed or canceled. The code can be seen below. It seemingly works until it crashes with an FatalExecutionEngineError. I do not make any P/invoke or unsafe calls.

   public class Fetcher
    {
        private List<ItemsBoundToUI> uiItems;
        public async Task<bool> Fetch()
        {
            List<Task> currentlyRunningTasks = new List<Task>();


                var src = new CancellationTokenSource();


                foreach (var channel in this.uiItems)
                {
                    var task = FetchForItem(channel, src.Token);
                    currentlyRunningTasks.Add(task);
                }

            bool wasCancelled = await Task.Factory.ContinueWhenAll(currentlyRunningTasks.ToArray(),
                                                                    (s) =>
                                                                    {
                                                                        bool wasC = s.Any(ss => ss.IsCanceled);

                                                                        return wasC;
                                                                    }
                                                                    );


           return !wasCancelled;
        }

        private async Task FetchForItem(ItemsBoundToUI channel, CancellationToken src)
        {
            var subitems = await dataRepository.GetSubItemsAsync(channel.ID);

            if (src.IsCancellationRequested)
                return;
            channel.SubItems = subitems;
        }
    }

The error message says

The runtime has encountered a fatal error. The address of the error
was at 0x6c108144, on thread 0xd94. The error code is 0xc0000005. This
error may be a bug in the CLR or in the unsafe or non-verifiable
portions of user code. Common sources of this bug include user
marshaling errors for COM-interop or PInvoke, which may corrupt the
stack.

How is it possible to wait until all the tasks have finished, or until they are cancelled and then return a value indicating whether they finished or were cancelled?

  • 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-04T10:47:52+00:00Added an answer on June 4, 2026 at 10:47 am

    The FatalExecutionEngineError sounds like a CLR bug. Please develop a minimal repro and report it to Microsoft via Microsoft Connect.

    It’s best to let cancellation work the way it was designed (via exceptions). To await multiple tasks, use Task.WhenAll.

    public class Fetcher
    {
      private List<ItemsBoundToUI> uiItems;
      public async Task<bool> Fetch()
      {
        List<Task> currentlyRunningTasks = new List<Task>();
        var src = new CancellationTokenSource();
        foreach (var channel in this.uiItems)
        {
          var task = FetchForItem(channel, src.Token);
          currentlyRunningTasks.Add(task);
        }
    
        try
        {
          await Task.WhenAll(currentlyRunningTasks);
          return true;
        }
        catch (OperationCanceledException)
        {
          return false;
        }
      }
    
      private async Task FetchForItem(ItemsBoundToUI channel, CancellationToken src)
      {
        var subitems = await dataRepository.GetSubItemsAsync(channel.ID);
        src.ThrowIfCancellationRequested();
        channel.SubItems = subitems;
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using TPL to make async calls to a method in my DAL which
I want to make a YAHOO.util.Connect.asyncRequest call, which not is async. Just like open(method,
I'm working on a Method which does some task asynchronously. Let's call it: AsyncMethod();
I have a Silverlight 3 application which needs to call WCF service. The WCF
I have the following method which uses implicit scheduling: private async Task FooAsync() {
The objective is to call a method which does it's thing then returns a
We're writing some code, in a single blocking method, which calls out to multiple,
I thought TaskEx.WhenAll would return when all the tasks gets finished which is passed
After doing an async $.ajax call, I need to highlight the table cell that
Say I have an async method which saves to file: async Task SaveToFileAsync() {

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.