PC Review


Reply
Thread Tools Rate Thread

Allowing a multi-threaded app to be stopped

 
 
Dave Wasden
Guest
Posts: n/a
 
      29th Sep 2003
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


 
Reply With Quote
 
 
 
 
Ginny Caughey [MVP]
Guest
Posts: n/a
 
      29th Sep 2003
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?
--
Ginny Caughey
Windows Embedded MVP

"Dave Wasden" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
Dave Wasden
Guest
Posts: n/a
 
      29th Sep 2003
Awesome. Thanks for this clarification. My subscription to the event was in
the wrong place.

"Ginny Caughey [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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?
> --
> Ginny Caughey
> Windows Embedded MVP
>
> "Dave Wasden" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multi-threaded and multi-AppDomain test scenario. Giulio Petrucci Microsoft C# .NET 7 9th Apr 2010 04:30 PM
multi-cores & multi-processors how does that effect threaded programming? Coaster Microsoft C# .NET 5 22nd Apr 2007 04:17 AM
need help w/ multi-threaded, multi-CPU tick count / stopwatch not_a_commie Microsoft C# .NET 5 14th Feb 2007 10:24 PM
Multi-Threaded UI Michael Tumy Microsoft Dot NET Framework Forms 4 15th Apr 2004 03:47 AM
Single-threaded vs. multi-threaded applications Opti_mystic Microsoft Windows 2000 Advanced Server 0 16th Oct 2003 08:41 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:16 AM.