hi,
i have a problem: i wrote a class that encapsulates communication with
database. i wont go into details, but i wanted to use threads to avoid
unresponsive ui so i did something more or less like this:
public void ExecuteScalar(string query)
{
this.query = query;
this.workingThread.Resume(); //the worker thread is suspended
}
private void WorkerThreadProc()
{
while(!this.threadStop)
{
if (this.query.Length > 0)
{
[check connection]
[retrieve data]
this.result = [assign result]
this.query = string.Empty;
Thread.Sleep(500);
}
}
}
now when thread finishes its job i call this.workingThread.Suspend();
after that the thread is rady to process next query. but then my app
eats whole processor time! i've checkd the workingThread state and its
96 what means it is in WaitSleepJoin state and is Suspended. in that
case why it is eating whole cpu time? does it mean that sleeping is "do
nothing loop"???
please help. how can i solve this problem?