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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T13:01:43+00:00 2026-05-20T13:01:43+00:00

I am writing a service that will connect to a single socket then read

  • 0

I am writing a service that will connect to a single socket then read the data which will be continuous and at times plentiful. The data I receive should then be handed off to another thread (in the service) to process, the reason is that the processing might take a while and I don’t want to block the receiving of the socket.

I was going to do this using the Begin or Async receive methods to process the data rather than having a thread running reading a concurrent queue or something. I need this to scale to possibly large amounts of data coming over the socket. Any suggestions?

  • 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-20T13:01:43+00:00Added an answer on May 20, 2026 at 1:01 pm

    I’m not sure how using asynchronous receive is going to help with the processing. As I understand it, you’ll have one thread that connects to the socket and reads a continuous stream of data. I assume that the thread can break that continuous stream into records of some kind, or at least blocks of manageable size. You then have to make that data available to one or more processing threads.

    I would strongly suggest that you do use a concurrent queue (actually a BlockingCollection) to communicate between the thread that’s reading the data and the thread or threads that will be doing the processing. There are several reasons I suggest using BlockingCollection:

    • It’s is easy to use – no explicit locking code
    • It does non-busy waits
    • It handles N readers and N writers efficiently

    Yours is a pretty typical producer/consumer application. The producer (the thread reading the socket) gets data, places it into the queue, and then one or more consumers (processing threads) can read and process the data. I can’t think of a simpler, more effective, or more efficient way to do this in .NET than with a BlockingCollection.

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

Sidebar

Related Questions

I'm writing a windows service which will be used to monitor some other services
I am writing a REST API for a service that will accept user contributed
I'm writing a service that has five different methods that can take between 5
I am writing a Windows service that pulls messages from an MSMQ and posts
I am currently writing a little bootstrap code for a service that can be
I'm writing a Win32 service in C++. I have a custom Assert macro that
I am writing a C# client that calls a web service written in Java
I am writing an application in C# that needs to run as a service
I'm writing a web service, and I want to return the data as XHTML.
I am currently writing an application that will allow a user to install some

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.