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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:46:02+00:00 2026-06-10T12:46:02+00:00

Hi I want to know more about how Async Callbacks works with Sockets .

  • 0

Hi I want to know more about how Async Callbacks works with Sockets.

Lets say from my UI Thread i call BeginRead method and pass in a callback named Read . From my understanding, BeginRead spawns a new thread (Thread A) hence code execution in the UI Thread can still proceed. The callback Read is executed in Thread A right? It blocks at the EndRead.

Then does Thread A auto close itself once the callback ends?

In the assumption that Thread A closes itself once the callback is called:::

Does it mean its safe to call another BeginRead inside Thread A just before it ends? This BeginRead will spawn a Thread B. Will Thread B fail to execute or to correctly put it, will it terminate at some point because the calling thread which is Thread A was ended? Or are threads not dependant on the caller at all?

  • 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-10T12:46:03+00:00Added an answer on June 10, 2026 at 12:46 pm

    You have a few misconceptions here. When you call BeginRead the callback that you specify will be called from within the internal thread pool of your application. There is typically no new thread started, though there might be one – it’s up the the internal scheduler of .NET.

    If you break your program in the debugger and go to the Threads view you should see a bunch of these threads named Worker threads. Typically all of them are sleeping and waiting for work. This is a much faster way than if BeginRead would spin up a thread each time you wanted to read. Instead it uses these workers that lay in the background, ready to go.

    And when the callback is completed the worker thread goes back to the pool, ready for more action.

    As for the rest of your questions:

    • The callback should not block in EndRead. There will be no block in your application. The IO data will be available either buffered, in which case the callback will run almost instantly. Or the data will be available much later. In that case the callback will be executed only after the data has appeared. This is an important point because it means that while you’re waiting for data there are no threads that wait for anything. The runtime takes case of the waiting and produces callbacks when data appears.
    • Yes, its safe to call another BeginRead from your callback. There are no dependencies. In fact, it is a good way to do IO that way.
    • Threads are never dependent on the caller. They are completely standalone and will die only when terminated naturally or when the process itself dies.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If you want to know more about why I'm doing this, see this thread...
I am new to rails. I want to know more about IP based Location,
I want to know a bit more about 'xmlns:mx=http://www.adobe.com/2006/mxml. Generally namespaces acts as the
I want to know more about the casting (like static cast, dynamic cast, const
I found some but still want to know more about them. Any of you
I've started working with jQuery UI. I want to know more about the jQuery
Hi I'm new in Javascript OO and want to know more about about inheritance.
I have below error msg and I want to know more information about what
I want to know more in detail about th developer runtime of silverlight what
I want to know more about OOP in PHP 5.2. Can anybody help me

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.