Making a Command Nonreentrant

To make a command nonreentrant

  1. Declare a static Boolean variable in your application for each command you wish to be nonreentrant. Statically initialize each variable to FALSE.
  2. Whenever a user enters the command or action you want to prevent reentrancy to, first check its static Boolean variable. If it is FALSE, set it to TRUE and continue the command. If it is TRUE, the command is being reentered, so post a message asking the user to complete the command in the other document that it is being used in.
  3. Always set the Boolean variable back to FALSE when the command is completed, canceled, or terminates for any reason.