title: Delphi thread that waits for data, processes it, then resumes waiting
body: <p>I need to create a thread in Delphi with the following characteristics:</p>
  
  <ul>
  <li>Waits until the main thread adds data to a shared queue.</li>
  <li>Processes all the data in the queue, returning the results to main thread (for this last part I'll just send messages to the main window). Processing is time-consuming, so new data may be added to the queue while the worker thread is processing previous entries.</li>
  <li>Resumes waiting, using as little cpu cycles as possible.</li>
  </ul>
  
  <p>I cannot send messages to the thread, since it does not have a window handle. </p>
  
  <p>Should I be using some variant of WaitForObject? If so, what would the wait be for? If not, then how can I keep the thread waiting, then awake it when new data comes down the queue?</p>
  
  <p><em>I've read <a href="http://www.eonclash.com/Tutorials/Multithreading/MartinHarvey1.1/ToC.html" rel="noreferrer">Multithreading - The Delphi Way</a>, which doesn't seem to answer my question. Perhaps  <a href="http://code.google.com/p/omnithreadlibrary/" rel="noreferrer">OmniThreadLibrary</a> can do what I need; I can't tell since there's little documentation. I don't know enough about threads in general to figure out if the library will help here and how to use it (or even why to use it instead of just working with TThread descendants).</em></p>