speed up app?
I am deving an application for smartphone. It sends and recieves data from a server computer (also made in C#)
The thing is, I have a while loop going on in order to check for incoming data and it can slow down the application a fair amount
Is there a better way to check for incoming data without the need for a while loop going on continuesly?
void Recieve(){while (!this.readData &&this.ns.CanRead) { if(this.ns.DataAvailable){ byte[] incomingData =newbyte[64];int theData = ns.Read(incomingData, 0, incomingData.Length);this.HandleIncomingData(incomingData);this.readData =false;} } } |
This method is running on a seperate thread and makes no difference when not running it on a seperate thread.
the "HandleIncomingData" basically checks for the incoming byte and I do actions according to it.
Wierd thing is, when the data I want has been recieved, it doesnt do anything apart from locking up the application (no exceptions)
however if i set a breakpoint and debug the application, everything is fine and does what I want it to do (display data)
So, 2 Q's.... 1 about performance and the 2nd is why it doesnt do what I tell it to do unless I hit a breakpoint and run it from there...
Any advice is much appreciated

