Thanks for your ideas.
I changed my code from Thread.CurrentThread.Suspend() to
Thread.Sleep(Timeout.Infinite)
To let it awake I use myThread.Interrupt().
Unfortunately I cannot let the thread finish and use a new one. The problem
has to do with unmanaged code. To terminate my thread I subscribe to the
System.Windows.Forms.Application.ApplicationExit event from within my thread
so that it can Abort() itself.
As far as I can see this solution works for me but I will look at the
IsBackground property to see if this is a more elegant way.
Thanks,
Guido
"Willy Denoyette [MVP]" wrote:
"Guido Kraus" <gu*********@newsgroup.nospam> wrote in message
news:06**********************************@microsof t.com... Hi,
I have a VB Windows Forms app that has a single form ('MainForm').
MainForm
has a shared (C#: static) class variable that holds a reference to a newly
created Thread. This thread does some work and then supends itself
(Thread.CurrentThread.Suspend()). When the user closes the MainForm window
the application does not quit since it has one thread that is not finished
(the one which is suspended).
What is the suggested way of quitting an application that might have
suspended and/or waiting (sleeping) threads?
Thanks for any ideas,
Guido
Don't suspend a thread use a wait primitive like an event instead.
BTW. Thread.Suspend will go away in v2.0.
Willy.