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:
Code:
void Server::TimerShot() { CWorkThread *WThread = new CWorkThread(this); connect(WThread, SIGNAL(finished()), WThread, SLOT(deleteLater())); }
Code:
void CWorkThread::run() { CWorkFiles files; sInfo = db.GetNewTask(); db.CloseDB(); //File Operation blocked. While the file is not copied more than walk. { //OK db.ChangeState(3, sInfo.cObjName, sInfo.cFileName, sInfo.nSysId); db.CloseDB(); break; } else { //ERROR db.ChangeState(33, sInfo.cObjName, sInfo.cFileName, sInfo.nSysId); db.CloseDB(); break; } }