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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:49:43+00:00 2026-05-19T09:49:43+00:00

I have a C# HttpListener that runs on a single thread and parses data

  • 0

I have a C# HttpListener that runs on a single thread and parses data sent to it by another program. My main problem is not all the data sent to the server is received. I only assume this is due to the limitations of it being run on a single thread. I have searched high and low for a simple multi-threading solution so it may receive al the data sent to it, and came up empty handed. Any help in transforming this into a multi-threaded application would be much appreciated.

    private void frmMain_Load(object sender, EventArgs e)
    {
        Thread t = new Thread(new ThreadStart(ThreadProc));
        t.Start();
    }

    public static void ThreadProc()
    {
        while (true)
        {
            WebBot.SimpleListenerExample(new string[] { "http://localhost:13274/" });
            //Thread t = new Thread(new ThreadStart(ThreadProc));
            //t.Start();
            Application.DoEvents();
        }
    }
  • 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-19T09:49:44+00:00Added an answer on May 19, 2026 at 9:49 am

    First thing first: verify that your hypothesis is indeed correct. You need to check:

    1. How much data is sent
    2. How much data is received
    3. How long does it take to send the data
    4. How long does it take to operate on the data

    HTTP works over TCP, which generally guarantees delivery, so even if it will take a long time, your server should be getting all the incoming information.

    That said, if you still want to make the process multi-threaded, I would recommend the following design:

    1. One thread like you have right now (LISTENER THREAD), that accepts incoming data.
    2. Another set of threads that will process the incoming data (WORKER THREADS).
    3. The listener thread will only receive the data and place it in a queue.
    4. The worker threads will dequeue the queue and operate on the data.

    Several notes and things to think about, though:

    1. Take care of thread synchronization – specifically, you need to protect the queue.
    2. Think if it matters which worker thread will get the data. If there are several chunks that need to be taken care of a specific worker thread, you’ll need to address this problem.
    3. In some cases, if there is a very high load on the listener thread, the queue may become a bottleneck, or more precisely – the locking on the queue may become a bottleneck. In this case I would recommend moving into a model of N queues for N worker threads, and have the listener just pick one in a round-robin fashion. This will minimize the locks and actually since you’ll have one reader and one writer you can even get away without a lock (but this is out of scope for that answer).

    Yet another option would be to use a thread pool. A thread pool is a pool of threads that are hibernating until they are needed. When the listener gets an incoming input it will allocate it to a free thread, or will enlarge the pool if needed; this way you don’t have a queue, and your threads are optimally used.

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

Sidebar

Related Questions

i have five forms in my c# project. one host an httplistener that i
I have an application that uses HttpListener, I need to know when the client
I'm having a little trouble with relative URIs I have a simple HttpListener app
I'm developing an application that is so far using HttpListener to provide a small
I wrote a simple WebServer using HttpListener class (.net 2.0) It seems that It
I'm trying to use the HttpListener class in a C# application to have a
Have you noticed that every 10 questions on this site is about jQuery? Anyway...
I have a multidimensional array and I want to have the output that only
Have just started using Google Chrome , and noticed in parts of our site,
Have you ever seen any of there error messages? -- SQL Server 2000 Could

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.