TERMWAIT: Launches Child Task and Waits

TERMWAIT launches a child task and waits for it to
terminate before executing specific code. The program uses
TOOLHELP library functions for this purpose and launches
Notepad as an example.

TERMWAIT installs a notification callback function using
NotifyRegister before calling WinExec to launch the child
task. All system tasks call this notification function
before termination. The notification function calls
TaskFindHandle to obtain TASKENTRY information about the
terminating task and consequently determines if TERMWAIT
launched the terminating task.

TERMWAIT sets the bChildIsExecuting global variable to
TRUE when the child task is spawned and sets it to FALSE
after the child task has terminated. Any code that should
not be executed while the child is running can check the
value of bChildIsExecuting. Menu choices that may cause re-
entrancy problems during the wait should be grayed. The
AfterChildHasTerminated function contains code that can be
executed only after the child task has terminated.

 If an application needs to keep track of a number of child
tasks, it can process both NFY_STARTTASK and NFY_ENDTASK
in the NotifyRegister callback function. GetCurrentTask
will return the handle of the task that called the
notification. This information can be managed by the
parent task. Although tasks cannot share the same handle,
task handles can be re-used. If one task terminates and
another one starts, the new task can have the same handle
as the task that just terminated. This is not a problem if
the parent task uses the NotifyRegister callback function
to detect when a task has terminated.

TERMWAIT was built and tested under Microsoft(R)
Windows(TM) version 3.1. TERMWAIT requires Windows 3.1 to
build, but has been compiled for 3.1 and 3.0
compatibility. TOOLHELP.DLL was not shipped with Windows
3.0; you must copy this library to the \WINDOWS\SYSTEM
directory to run TERMWAIT under 3.0.

KEYWORDS: PR-CD2; GetCurrentTask; NotifyUnRegister;
TaskFindHandle
