Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. worker thread

worker thread

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    BaShOr
    wrote on last edited by
    #1

    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?

    B 1 Reply Last reply
    0
    • B BaShOr

      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?

      B Offline
      B Offline
      Bob Ciora
      wrote on last edited by
      #2

      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

      B 1 Reply Last reply
      0
      • B Bob Ciora

        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

        B Offline
        B Offline
        Bob Stanneveld
        wrote on last edited by
        #3

        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[^]

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups