One option you have is to wait on the future or future watchers when exiting.
Basically close the window and call watcher.waitForFinished() before exiting.
Cheers,
_
One option you have is to wait on the future or future watchers when exiting.
Basically close the window and call watcher.waitForFinished() before exiting.
Cheers,
_
Hossein (12th October 2015)
Thank you verymuch sir
But this would continue to execute the method till it ends, right? and this is not a wanted outcome.
suppose the user closes the app, thinking all is freed (resources I mean) and then tries to run or do whatever he was doing (possibly re executing the lengthy method )
How can I get rid of that spawned thread immediately? Is there anyway for that?
From QTimer doc : Timers will never time out earlier than the specified timeout value and they are not guaranteed to time out at the exact value specified. I suggest using the class QElapsedTimer.
Hossein (12th October 2015)
QtConcurrent uses the global instance of QThreadPool, you don't have any control over which thread is being used.
Stopping a thread requires that the code run by the thread regularily checks for a stop condition and a way for the main thread to make that stop condition to become true.
In the very special case of exiting the application, it might be OK to call terminate(), but I recommend to avoid that until it is the last resort.
Cheers,
_
Hossein (12th October 2015)
thanks, but I cant use that, I need to update the time ( I need to show it to the user as well, and when I checked the documents, I couldn't find any events for QElapsedTimer that I can use instead of timers.
That method is atomic, I mean I cant put anything into that, Its a member function of of a class which I have no control over it.
Hossein (12th October 2015)
Bookmarks