Thursday, 15 September 2011

c++ - How to check boost thread is running and Kill it -


In my program, it starts a boost thread and holds the handler as a member of the main thread. When the user clicks the cancel button I also need to check the start thread to run still, and if it is running then it is necessary to kill that specific thread. Here is the pseudo code.

Fraud Thread

  int i = 1; Promotion: Thread: m_uploadThread = Promotion: Thread (Uploadfile, I);   

This method is used to ascertain that the thread is still running, but it is not working

  boost :: posix_time :: time_error timeout = boost :: posix_time :: milliseconds (2); If (this-> uploadfast.timed_join (timeout)) {// here should kill this thread}    

Return value means that the thread is completed before the call timed out. And it looks like what you want

  if (! It-> uploadfast.timed_join (timeout))    

No comments:

Post a Comment