Prompt how to implement the following features:

My application is a lot Thread server and receives the job to copy files from one directory to another. After receives a job is entered into the database and get in the queue.With the help of a timer, I queried the database every 10 seconds, and derive from the base of your new job. Each new task of copying a file is executed in a separate thread.Now you need to be able to suspend the execution in advance of copying the file / interrupt the flow.
Prompt how to make sure that I at any time to stop the flow.

application of this:


Qt Code:
  1. void Server::TimerShot()
  2. {
  3. CWorkThread *WThread = new CWorkThread(this);
  4. connect(WThread, SIGNAL(finished()), WThread, SLOT(deleteLater()));
  5. WThread->start(QThread::HighPriority);
  6. }
To copy to clipboard, switch view to plain text mode 



Qt Code:
  1. void CWorkThread::run()
  2. {
  3. CWorkFiles files;
  4.  
  5. sInfo = db.GetNewTask();
  6. db.CloseDB();
  7.  
  8. //File Operation blocked. While the file is not copied more than walk.
  9. if(files.CopyFileExPrg(QDir::toNativeSeparators(sInfo.cFileName),
  10. QDir::toNativeSeparators(sGInfo.cDstPath), true, false, sInfo.nSysId))
  11. {
  12. //OK
  13. db.ChangeState(3, sInfo.cObjName, sInfo.cFileName, sInfo.nSysId);
  14. db.CloseDB();
  15. break;
  16. }
  17. else
  18. {
  19. //ERROR
  20. db.ChangeState(33, sInfo.cObjName, sInfo.cFileName, sInfo.nSysId);
  21. db.CloseDB();
  22. break;
  23. }
  24. }
To copy to clipboard, switch view to plain text mode