Surely in that situation Interrupt is better anyway - it will do the msa ejob and will be safe even if you happen to be wrong about it being in a lng wait (maybe its just woken up)
Regards
Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog
I would add to your examples that it is safe to terminate a background
thread, when you know it's in a wait state.
EG
This thread
void threadProc()
{
while (!shutdown)
{
WaitForSingleObject(flarg,INFINITE);
... some short-running code
}
}
Can be safely aborted by this:
shutdown = true;
if (!backgroundThread.join(1000))
{
backgroundThread.abort();
}
Meaning you can safely abort background threads which you know to be in a
long wait, and which are coded to exit on an exception.
Now, if possible you should code a signal to abort the wait state, but
that's really neither here nor there. Sometimes it's appropriate to have a
long-running wait on some object, and if you have confidence that a
background thread is in that state, you can abort it if you need to.
David
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (
http://www.grisoft.com).
Version: 6.0.775 / Virus Database: 522 - Release Date: 08/10/2004
[microsoft.public.dotnet.framework]