How about suspendProcess

  • Thread starter Thread starter Denis @ TheOffice
  • Start date Start date
D

Denis @ TheOffice

I see that there is an option to OpenProcess for suspend/resume.
I do not see the SuspendProcess nor ResumeProcess call for it?

In the case that there is no such thing Is there a way to do the equivalent?


Denis
 
Denis @ TheOffice said:
I see that there is an option to OpenProcess for suspend/resume.
I do not see the SuspendProcess nor ResumeProcess call for it?

In the case that there is no such thing Is there a way to do the equivalent?

Call SuspendThread for each thread in the process.
 
Gary Chanson said:
Call SuspendThread for each thread in the process.
I see.

Should I suspend thread in a certain order?
Is there a way to locate the main thread?

Denis
 
Denis @ TheOffice said:
I see.

Should I suspend thread in a certain order?
Is there a way to locate the main thread?

There is no real concept of a main thread in Windows. When you enumerate
the threads, the first thread will typically be the first one created and is
probably what you might think of as the main thread.

There's no way to know if it matters what order you suspend them in. If
its critical that all threads get suspended at essentially the same time (keep
in mind that this doesn't really mean much in a multitasking environment, but
might in a multiprocessor environment), push up the priority of the thread
doing the suspending so that it won't get preempted while it's working.
 
Gary Chanson said:
There is no real concept of a main thread in Windows. When you
enumerate
the threads, the first thread will typically be the first one created and
is
probably what you might think of as the main thread.

There's no way to know if it matters what order you suspend them in.
If
its critical that all threads get suspended at essentially the same time
(keep
in mind that this doesn't really mean much in a multitasking environment,
but
might in a multiprocessor environment), push up the priority of the thread
doing the suspending so that it won't get preempted while it's working.

You could sort them based on the priority of the threads being suspended...
suspend the lowest priority threads first, since that's either essentially a
no-op (a higher priority thread is runnable), or suspends the entire app (if
every higher priority thread is blocking). Or suspend the highest priority
threads first, since those are likely to be watchdog monitors which might
kill the entire process if you get it wrong.
 
Back
Top