worker thread
-
I'm using a worker thread in order to load images and manipulate them in the background. But I have a problem shutting the thread down during execution. As I am using a library which does most of the work for me (DevIL image lib) I cannot poll for a running state. Loading a big image may require a couple of seconds! How should I deal with this problem?
-
I'm using a worker thread in order to load images and manipulate them in the background. But I have a problem shutting the thread down during execution. As I am using a library which does most of the work for me (DevIL image lib) I cannot poll for a running state. Loading a big image may require a couple of seconds! How should I deal with this problem?
-
If you can always eventually kill it when it returns from one of the library routines, you could always put up a "Shutting down..." type of banner just to let users know that the program isn't hung. Bob Ciora
Hello, You should use flags to shut the thread down. You could use the
[TerminateThread()](http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/terminatethread.asp)[[^](http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/terminatethread.asp "New Window")]
or[endthread()](http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt__endthread.2c_._endthreadex.asp)[[^](http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt__endthread.2c_._endthreadex.asp "New Window")]
routines, but these are not safe! See this[^] article for more information on this 'right' way to stop worker threads. Hope this helps :-D Behind every great black man... ... is the police. - Conspiracy brother Blog[^]