program thread won't exit VB.NET

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • seraieis
    New Member
    • Apr 2008
    • 60

    program thread won't exit VB.NET

    I'm working on developing an application that has several BackgroundWorke rs. If I use any of the functions that use one of the workers, when I go to close the application, the process stays running in the background. I have to go into Task Manager to exit it, which I can't expect users to do.

    Does anyone have any suggestions as to why this is happening? I've tried everything I can think of, including aborting the threads, and calling .Dispose() on them.

    Any help would be greatly appreciate!
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    One of your background threads is still running. You should work to isolate which one it is, and go through and make sure you don't have any try/catch blocks that would ignore the ThreadAbortExce ption

    Comment

    • seraieis
      New Member
      • Apr 2008
      • 60

      #3
      I went through the code and modified the try/catch blocks to display all exceptions, rather than handling them. That background worker is still going after I close the program.

      What makes this even weirder, is that in the FormClosing event, when I checked the workers IsBusy property, they all return False.

      Is there a way to access the thread behind the backgroundworke r and force it to abort?

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        I've never used them, I prefer threads and timer threads, so I am not sure.

        Does .WorkerSupports Cancellation = true? I would think you could just .Dispose() of them. (Maybe call CancelAsync() first?)

        Comment

        • seraieis
          New Member
          • Apr 2008
          • 60

          #5
          I tried that also and it doesn't cancel the thread.

          I'll try rewriting it so that it uses threads, rather than BackgroundWorke rs. I'll let you know how it goes!

          Comment

          • Plater
            Recognized Expert Expert
            • Apr 2007
            • 7872

            #6
            I think for backgroundworke rs you need to call Application.DoE vents() to get it to finalize

            Comment

            Working...