Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
tools
vsnet.act
vsnet.debugging
vsnet.documentation
vsnet.enterprise.tools
vsnet.general
vsnet.ide
vsnet.jlca
vsnet.servicepacks
vsnet.setup
vsnet.vsip
vsnet.vss
vsnet.vstools.office
vstudio.development
vstudio.extensibility
vstudio.general
vstudio.helpauthoring
vstudio.setup
vstudio.sourcesafe
  
 
date: Wed, 13 Aug 2008 15:12:51 +0100,    group: microsoft.public.vstudio.general        back       


Thread suspend count   
Hi,

If I create a thread in the non-suspended state and then call:

SuspendThread(hThread);

how do I know that the thread isn't already suspended when I call this? 
Ideally, I'd like something like this:

if (GetThreadSuspendCount(hThread) == 0)
    SuspendThread(hThread);

but the MSDN documentation is a little unhelpful here.

Thanks,
Alain
date: Wed, 13 Aug 2008 15:12:51 +0100   author:   Alain Dekker

Re: Thread suspend count   
Though this is offtopic here:

Suspending a thread is an operation which should not be used in most 
designs. It only makes sense when you develop a debugger. Suspending a 
thread in the same process is very dangerous operation, because it may leave 
you with an owned critical section; this will lead to a deadlock.

If you suspend a thread (suppose it's an external debugger), you should not 
care if a thread is already suspended; you can call SuspendThread anyway. 
You shoud only be concerned that you don't call ResumeThread more times than 
you SuspendThread.

For debugging purposes, SuspendThread returns current suspend count.

The thread suspend cound in theory could change at any moment. In practice, 
if only you mess with thread suspend, you should know the count anyway.

"Alain Dekker"  wrote in message 
news:umfBP5U$IHA.3392@TK2MSFTNGP03.phx.gbl...
> Hi,
>
> If I create a thread in the non-suspended state and then call:
>
> SuspendThread(hThread);
>
> how do I know that the thread isn't already suspended when I call this? 
> Ideally, I'd like something like this:
>
> if (GetThreadSuspendCount(hThread) == 0)
>    SuspendThread(hThread);
>
> but the MSDN documentation is a little unhelpful here.
>
> Thanks,
> Alain
>
date: Wed, 20 Aug 2008 20:16:14 -0700   author:   Alexander Grigoriev

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us