Optimizing Multi-Use Object Applications


You can optimize performance of multi-use objects by using multiple execution threads. With multiple threads, each new multi-use object runs independently - one client can't tie up the remote application for other clients. Figures T.4 and 21.5 illustrate how multiple threads avoid conflicts between clients.

FIG. 21.4

Multi-use objects running in a single thread force clients to wait as objects compete for the execution thread.

FIG. 21.5

Run multi-use objects in separate threads to prevent one client from tying up the remote application for other clients.

To make an application multithreaded, follow these steps:

  1. From the Project menu, choose project Properties, as shown in Figure 21.6.

    FIG. 21.6

    The Unattended Execution check box is grayed if your project contains forms. Only applications without forms can be multithreaded.

  2. Select the Unattended Execution check box on the Project Properties dialog box and click OK.
  3. Compile your project.

There is one big restriction on creating multithreaded, multi-use objects - the application can't include forms. If your project includes one or more form modules, the Unattended Execution check box will be grayed, and you can't select it. If you add a form to a project with the check box selected, it will be deselected automatically.

You can work around this problem by using the multithreaded application to dole out running instances of single-use application objects. This type of multi-use application is called a pool manager and it is discussed in the later section "Optimizing Single-use Object Applications."