Re: Multiple Threads Within the IDE

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Doug Thews (dougthews_at_removeme.ddconsult.com)
Date: 10/08/04


Date: Fri, 8 Oct 2004 13:57:10 -0500

So, what is the recommended method for shutting down threads spun off my a
main form in a WinFOrms app?

1. Create all worker threads by setting the IsBackground property to true?
2. Call Thread.Interrupt() followed by Thread.Join() within the Form's
Close event for all worker threads?

-- 
Doug Thews
Director, Customer Solutions
D&D Consulting Services
----------------
Visit my Tech Blog at:
http://www.ddconsult.com/blogs/illuminati/
"Richard Blewett [DevelopMentor]" <richardb@develop.com> wrote in message 
news:esKObLRrEHA.2008@TK2MSFTNGP12.phx.gbl...
> well if you just want the trheads to terminate when teh main thread does 
> set their IsBackground property to true. If you want the threads to come 
> down in a controlled fashion, signal them (by an event, flag or Interrupt) 
> and issue a Join on them before the form closes.
>
> The main issue is that threads created uwing the Thread class will, by 
> default, keep your process running.
>
> Regards
>
> Richard Blewett - DevelopMentor
> http://staff.develop.com/richardb/weblog
>
> 
> nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/>
>
> I was noticing that when I run a multi-threaded app from within the IDE 
> and
> then I close the main form (which spun off all of the threads), that the
> Stop/Pause VCR buttons in the debugger are still available & working. It's
> like closing the form did not actually cancel the threads.
>
> From my earlier discussions on the newsgroup, I know how people already 
> feel
> about Thread.Abort(), so I was wondering what I need to do to "clean up"
> when closing a main form that has spun off worker threads (I was under the
> impression that this cleanup would automatically happen, but seeing the
> Stop/Pause VCR buttons on the debugger being active & working tell me
> otherwise).
>
> Any thoughts would be appreciated.
>
> --
> Doug Thews
> Director, Customer Solutions
> D&D Consulting Services
> ----------------
> Visit my Tech Blog at:
> http://www.ddconsult.com/blogs/illuminati/
>
>
>
>
>
> ---
> Incoming mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.771 / Virus Database: 518 - Release Date: 28/09/2004
>
>
>
> [microsoft.public.dotnet.languages.csharp] 

Quantcast