Composing Parts for Multiple Threads

To perform processing of a visually composed application in multiple threads, use the following parts:

IVBThread
For threads containing GUI parts. Encapsulate logic to be performed on a GUI thread in a composite part based on IVBThread. Creation of GUI parts must be deferred until they are referenced. This deferral is the default for parts added to the free-form surface.

IVBNonGUIThread
For threads containing only non-GUI parts. Encapsulate logic to be performed on a non-GUI thread in a composite part based on IVBNonGUIThread.

IVBHomeThreadNotifier
For notification between threads, which enables connections between parts in multiple threads. Encapsulate knowledge of a secondary thread in a composite part based on IVBHomeThreadNotifier. The home thread notifier transfers notifications from an embedded thread part.

The reporting scheme from the secondary thread is likely to depend on whether the thread terminates after performing a single task.

As a simple example of composing multiple-thread processing, you might compose a fixed database query as follows:

  1. Create a QueryThread part based on IVBNonGUIThread. In this part, do the following:
    1. Add a query part to perform the query.
    2. Connect the IVBNonGUIThread aboutToRun event to the query action of the query part.
    3. Promote the query result to the QueryThread part interface as a result attribute.

  2. Create a DBQuery part based on IVBHomeThreadNotifier. In this part, do the following:
    1. Add a QueryThread part.
    2. Promote the QueryThread start action to the DBQuery part interface as performQuery.
    3. Promote the QueryThread aboutToTerminate event to the DBQuery part interface as queryDone.
    4. Promote the QueryThread result attribute to the DBQuery part interface.

  3. In a part that needs to perform a query request, do the following:
    1. Add a DBQuery part.
    2. Connect to the DBQuery performQuery action.
    3. Connect the DBQuery queryDone event to the attribute that needs the result.
    4. Connect the DBQuery result attribute to the queryDone-to-attribute connection.


Related procedures
Working with VisualAge User Interface Parts