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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:45:54+00:00 2026-06-08T03:45:54+00:00

I have three tasks A, B, C. B must run before C, but A

  • 0

I have three tasks A, B, C.

B must run before C, but A can run in parallel to both of them. This is logic that has recently changed, and the logic we currently have works fine, I just wondered if there is a better solution to what we currently have:

public void RunTasks(...) {
    Action<IRunnableTask> runner = task => 
    {
        if (task.ShouldRun(request))
        {
            task.Run(request, response);
        }
    };

    // run parallel tasks
    Parallel.ForEach(parallelTasks, runner);

    // run serial tasks
    Array.ForEach(serialTasks, runner);
}

Here, A and B would be parallel tasks, C is in the list of serial tasks. The problem is here that the code will wait for A to finish before C can start, which is unnecessary.

So, is there a nice clean solution, or do I need to start putting in callbacks and whatnot?

  • 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-08T03:45:56+00:00Added an answer on June 8, 2026 at 3:45 am

    You could make use of Tasks from the TPL.

    You could run Tasks B and A at the same time, then have task C run as a continuation of Task B

    e.g.

    Task.Factory.StartNew(()=>TaskA());
    Task.Factory.StartNew(()=>TaskB()).ContinueWith(t=>TaskC(t));
    

    In the continuation of TaskB, you can pass in the Task to get any result of TaskB passed into the TaskC method.

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

Sidebar

Related Questions

Imagine I have two (three, four, whatever) tasks that have to run in parallel.
I have a long-running process that must run every five minutes, but more than
I have an app that has a BG module which is forced to run
i have task which takes a parameter and has three modes of results Example
I have an unordered tree. Each node represents a task that can be done
Have three divs in a container that I want to float over a large
I have three separate table variables in my Function, 1 of them is not
I know that in iOS, background apps can only be running Finite-length tasks (10
I have searched all the usual but come up empty. I must be doing
Overview: I have an application that sometimes must make something with celery- and if

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.