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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:24:01+00:00 2026-05-22T16:24:01+00:00

I would like to run a test against C# (I want to compare it’s

  • 0

I would like to run a test against C# (I want to compare it’s run speed to another language).
What I would like to do is create 100,000 threads in a chain, have each wait for a value from the thread before it, when it gets the value add 1 and pass the value to the next thread.
The idea is to see how quickly it can create those threads and add up to 100,000.
I have no idea how to write that code. I can do pieces of it like threading and timing, but I’m not sure how to string them together.

EDIT
It seems I also get to learn about my deficiencies in knowledge when it comes to Threading. So let’s assume that Thread Pooling (or some other low level method) is comparable, can anyone show me examples of that?

  • 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-22T16:24:02+00:00Added an answer on May 22, 2026 at 4:24 pm

    This scenario is exactly what the TPL is designed to achieve, in particular ContinueWith, or await in C# 5 parlance. Note that async != threading (although they are related), but the point is that you are actually trying to execute 100k tasks, not 100k threads. These two concepts are different. The TPL is the right way to do this. Always use an appropriate tool for the job.

    I’ll happily whip up a TPL example if you want… something not too far to:

    var root = new Task<int>(() => 0);
    var end = root;
    for(int i = 0 ; i < 100000 ; i++)
    {
        end = end.ContinueWith(last => last.Result + 1);
    }
    var watch = Stopwatch.StartNew();
    root.Start();
    end.Wait();
    watch.Stop();
    Console.WriteLine("{0} in {1}ms", end.Result, watch.ElapsedMilliseconds);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to run programmatically an instance of TestNG test. My test is
What I would like is for C-c C-c to run py.test and display the
I would like to be able to run a nose test script which accepts
I have a PHP app that I would like to test against various PHP
I'm using js-test-driver to run some tests and would like to test some code
I would like to run some validation checks against projects that jenkins builds. The
I have a Robotium test cases that I would like to run nightly using
I want to run containstable on test1 and test2 and would like to run
I've got some heavyweight process, which does some video processing. I would like run
I would like to run a jar file extracted from my java project 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.