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.
- If the thread is dedicated to a single task, such as a
database query, you can perform the task when the thread
is started and report the result when the thread
terminates.
- If the thread provides periodic results based on some
recurring event, the results must be reported whenever
the event occurs.
- If the thread supports requests on demand, each request
is performed when an action is called, and the result of
each request must be reported when the action is
completed.
As a simple example of composing multiple-thread processing,
you might compose a fixed database query as follows:
- Create a QueryThread part based on IVBNonGUIThread. In
this part, do the following:
- Add a query part to perform the query.
- Connect the IVBNonGUIThread aboutToRun
event to the query action of the query part.
- Promote the query result to the QueryThread part
interface as a result attribute.
- Create a DBQuery part based on IVBHomeThreadNotifier. In
this part, do the following:
- Add a QueryThread part.
- Promote the QueryThread start action to
the DBQuery part interface as performQuery.
- Promote the QueryThread aboutToTerminate
event to the DBQuery part interface as queryDone.
- Promote the QueryThread result attribute
to the DBQuery part interface.
- In a part that needs to perform a query request, do the
following:
- Add a DBQuery part.
- Connect to the DBQuery performQuery
action.
- Connect the DBQuery queryDone event to the
attribute that needs the result.
- Connect the DBQuery result attribute to
the queryDone-to-attribute connection.
Working with VisualAge User
Interface Parts