I have written an application which creates a few threads which each create one timer object and then wait for the timer messages to activate them and do their stuff and so on.
So basically the execute procedure looks like this:
While Not Terminated Do
//case 1) Application.HandleMessage;
//case 2) Application.ProcessMessages;
1) The Application goes in the idle state, responds to TTimer events, but does not return to the Execute function any more, therefore not checking the Terminated property any more and therefore never terminating!
2) The application repaints the windows and responds to termination requests, but I noticed it consumes all CPU resources (100%) which, of course, is unnacceptable.
3) The application not only consumes all CPU resources, but also doesn't respond to paint messages well.
What exactly does "idle state" mean? Does it mean that the the system suspends the application (or the thread) until a message is received? What would be a harmless message to send?
Do these functions affect Threads or the entire Application?