Allowing a multi-threaded app to be stopped

  • Thread starter Thread starter Dave Wasden
  • Start date Start date
D

Dave Wasden

I have an app that starts a second thread. This background thread runs while
the app is running. The thread loops, sleeping for a half second while
"isRunning" is true on the main form. Now, if the user goes to the running
programs list and kills my app, it disappears from the running program list,
but it is still running. If I manually set "isRunning" to false in debug
mode, then the app shuts down. Is there an event that occurs when an app is
stopped from the running programs list that I can use to set isRunning to
false. I have tried closed, closing, dispose, but none of these events occur
until the thread is stops.

Thanks, I am still new to threading.
Dave
 
Dave,

The Running Programs list shows the captions of the form(s) in your app, and the
Closing event should fire when that form is closed (and the app will stop when
the top level form is closed). Maybe the form you're closing in Running Programs
isn't the one whose Closing event you're trapping?
 
Awesome. Thanks for this clarification. My subscription to the event was in
the wrong place.
 
Back
Top