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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:34:13+00:00 2026-05-24T17:34:13+00:00

I need to test a Data Context and see what behavior it has under

  • 0

I need to test a Data Context and see what behavior it has under multiple simultaneous requests, for that I made a simple console application that [in theory] would send these requests:

private static DateTime startTime = DateTime.Now.AddSeconds(5);
public static Random rand = new Random();

static void Main(string[] args)
{
    const byte testThreads = 10;

    ThreadStart[] threadStarts = new ThreadStart[testThreads];
    Thread[] threads = new Thread[testThreads];

    for (byte i = 0; i < testThreads; i++)
    {
        threadStarts[i] = new ThreadStart(ExecutePOST);
        threads[i] = new Thread(threadStarts[i]);
    }

    for (byte i = 0; i < testThreads; i++){ threads[i].Start(); }

    for (byte i = 0; i < testThreads; i++){ threads[i].Join(); }
}

The called function is

private static void ExecutePOST()
{
    while (DateTime.Now < startTime) { }

    Console.WriteLine("{0} STARTING TEST", DateTime.Now.Millisecond);
    WebRequest webRequest = WebRequest.Create(/*URL*/);
    webRequest.ContentType = "application/x-www-form-urlencoded";
    webRequest.Method = "POST";

    string name = string.Format("Test {0}", Program.rand.Next(1000));

    byte[] bytes = Encoding.ASCII.GetBytes(/*PARAMETERS*/);
    Stream output = null;
    try
    {
        webRequest.ContentLength = bytes.Length;
        output = webRequest.GetRequestStream();
        output.Write(bytes, 0, bytes.Length);

        Console.WriteLine("{0}:{1}", DateTime.Now.Millisecond, name);
    }
    catch (WebException ex)
    {
        Console.WriteLine(ex.Message);
    }
    finally
    {
        if (output != null)
        {
            output.Close();
        }
    }
}

The output I get is:
Output

Can anyone please explain this behavior? Why is it stopping after two requests?

Thank you

  • 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-24T17:34:14+00:00Added an answer on May 24, 2026 at 5:34 pm

    Yes, this is because the number of connections per URL is limited to 2 by default – the connections are pooled.

    You’re hogging the connection by writing data to the request stream, but then never getting the response. A simple:

    using (webRequest.GetResponse()) {}
    

    at the end of the method is likely to sort it out. That will finish the request and release the connection to be used by another request.

    Also note that a using statement for the output stream would make your code simpler too.

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

Sidebar

Related Questions

I have table to test score data that I need to pivot and I
I need to test Perl Application ( File operation , Data base operation..etc )
I need to test a function that needs to query a page on an
I need to test a url that it does not end with .asp So
I need to test a web form that takes a file upload. The filesize
According to Misko Hevery that has a testability blog. Developers should avoid 'holder', 'context',
I'm trying to do a simple test post with jQuery in Kohana. Note that
the document http://developer.android.com/guide/topics/data/data-storage.html shows that there are multiple ways to save data, I need
I need to test whether various types of database objects exist in a given
I need to test a serial port application on Linux, however, my test machine

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.