C#: Handling terminate signal in TCP handler thread? -


I am using the TcpClient class in C #.

Every time a new TCP connection is requested, general behavior is to create a new thread to handle it. And for the main thread, these handler threads should be possible to finish at any time.

My solution for each of these handler threads is as follows:

  View the stream of 1 network dataAvailable Method 1.1 If new data is available then read and process new data 1.2 If the end of the stream itself ends, then check the end signal from the main thread 2.1. If the signal is terminated then 3 Goto 1 is terminated. The problem in this voting approach is that all these handler threads have important processor resources and especially if there is a large number of these threads. This makes it highly incompatible. 

Is there a better way to do this?

To learn how to do this ".NET route" without making new threads for each request See for


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -