I am developing a whole bunch of applications (that run on a network) and connect to common MySQL DB.
Of these applications, most of them involve waiting for a table to
1. Have a new row
2. Change a field
3. Retrieve rows by a field condition
My first instinct was to create a thread using System.Threading.Thread(AddressOf X)
and then have a While True loop inside that keeps on querying the table and then sleeps for a small amount of time (around 250 - 1000ms)
The problem is that the applications cause my System CPU usage to jump to 100% (mind you, I am using a Quad Core, 4GB RAM) and memory usage to hit 100% too!
It doesn't usually matter how many of the applications are running from a system.
So I got to thinking that maybe threading is not the answer. Is it because of the constant Querying?
Could anyone experienced in DB watching please help me out?
I already have the threading based applications. Most of them are like this:
1. MainUI.frm will have a Class
TableWatcherX
2.
TableWatcherX
will have a Start() method and a
private workingThread as Thread
3. In the Start() method, I put
workingThread = new Thread(AddressOf KeepWorking)
workingThread.Start()
4. In the method KeepWorking()
While True
Using ATable as <datasettable> = <datasetadapter>.getData
For each of the rows, process and do stuff...
End Using
End While</datasetadapter></datasettable>
Apparently something is wrong, as I've got my memory and CPU completely locked!
Any thoughts?