Hello!
I am developing Windows application which after sending a request to a
server will listen to response, a response will be infinite in length, but
will not be continuous in time.
What I have done is in a back thread I prepared infinite loop and there I am
checking for new packages. Its scheme looks like this:
***********************************
while(shallRun)
{
loopCounter++;
while(networkStream.DataAvailable)
{
networkStream.Read(buffer, 0, buffer.Length);
packagesCounter++;
//do some data manipulation here
//UpdateUI
}
}
***********************************
Unfortunatelly for every package my program is doing thousands or even
million "empty" loops. Probably that is why CPU is very high, and can even
get to 100%.
Do you know some other C# solution for reading infinite NetworkStream. Some
event OnNewData? or maybe some other solutions.
TIA
RGDS PSG
--
Nothing happens until somebody sells something.
Nic sie nie dzieje, poki ktos komus czegos nie sprzeda.
http://kickme.to/psg