I don’t quite follow: are you saying that if one of the TCP sockets is receiving data—triggering the dataAvailable event—it won’t process any other code until that execution finishes?
So, would 40 TCP sockets receiving data continuously block all other application activity, including timers?
Unfortunately, the socket and timer events are all running on the main thread which means only one method can run at a time.
You need to make the DataAvailable events do as little as possible - ie: add the incoming data to a buffer and process it via a thread.
The enhancement which I referred to in my previous post is for sockets to use preemptive threads which would free the main thread to allow the timer to operate correctly.
you could also run a thread and compare a datetime and then do what you need to do.
and with Preemptive Threads it could run at different cpu core too.
i think is that the best approach is create 2 apps, one for listeners and other to elaborate buffer (Buffer = same local sqllite db for listener app end for queque elaborator app ) , the second app (queque elaborator) in not impatted from the tcpsocket of the firs app and can use premptive threads and his timer
I mean, instead of calling .ReadAll directly from the DataAvailable event, call this method from a Thread (it doesn’t need to be a Preemptive Thread, it’s just I/O blocking)
Excuse me Ricardo ..
Just out of curiosity: if I run the same projec which currently runs on Windows Server 2019 (or Windows 10/11 Pro in debug mode ) on Linux, will I get better results?
In other words, on Linux (using the corresponding Linux executable), does the constant reception activity from 30/40 TCP sockets impact the main thread in the same way blocking timer code execution or are they handled more effectively?
Thank you Greg
but if i have 30 or 40 TCP sockets and these recieve a large amount of data simultaneously, I believe the main thread will remain busy and the timer action won’t be executed
i think that this is the same if i sublcass tcp socket or if i use thread to read data from tcpsocket
im curios if this is limit of using tcpSocket on windows and non if i use this on linux or if it is limit of tcp socket component on all platforms