
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Determining Whether a Process Has Stopped Responding
|
447
menu item. This step will display the Property Pages dialog box for this project.
Next, click the Configuration Properties node in the tree on the left side of this dia-
log box. In the control to the right of this tree, find the line entitled Conditional
Compilation Constants. On this line, you may add or remove any preprocessor iden-
tifiers that you want.
The
#if and #elif directives determine what code within a member is to be com-
piled. For example:
public void MyMethod( )
{
#if (TRACE)
Method1( );
#elif (DEBUG)
Method2( );
#else
Method3( );
#endif
}
MyMethod will call Method1 when TRACE is defined, Method2 if TRACE is undefined and
DEBUG is defined, and Method3 if both TRACE and DEBUG are undefined.
See Also
See the “C# Preprocessor Directives” and “ConditionalAttribute Class” topics in the
MSDN documentation.
8.5 Determining Whether a Process Has Stopped
Responding
Problem
You need to watch one or more processes to determine whether the user interface
has stopped responding to the system. This functionality is similar to the column in
the Task Manager that displays the text Responding or Not Responding, depending
on the state of the application.
Solution
Use the method and enumeration shown in Example 8-2 to determine whether a ...