InitiateThread code template

Top  Previous  Next

When opening an MDI window from an Application Frame, you must initiate an execution thread. This Code template provides an easy way to initiate a thread.

When you START a procedure on its own thread, the procedure and its window operate independently of other threads in the same program; that is, the end user can switch focus between each execution thread at will. These are "modeless" windows.

If you don't initiate a new thread, the program behavior depends on whether the procedure's window has the MDI attribute. A non-MDI child window on the same thread as its parent, blocks access to all other threads in the program. This is an "application modal" window. When the application modal window closes, the other execution threads are available again. An MDI child window on the same thread as its parent, blocks access only to its parent window. When the MDI child window closes, its parent window regains focus.

In the Prompts for Initiate Thread dialog, simply name the procedure that opens the MDI window. Optionally, you can modify the size of the stack to allocate to the new execution thread. The default stack is 25,000 bytes.

You can optionally add a line of code to execute if the application was unable to open the thread. Type in the edit box labelled Error Handling. For example,

MESSAGE('Could not Start Thread','Error',ICON:HAND)

would display a message box with the halt (hand) icon, if the thread failed to start.

You can add a procedure name to call upon an error by typing the name of the procedure in the Error Handling box. You would then add the procedure to the Application Tree with the Insert Procedure command.