Re: Objects in VM files

GWRepNate@aol.com
Tue, 26 Nov 1996 11:34:30 -0500

In a message dated 96-11-25 11:23:17 EST, GWRepNate writes:
> > I tried fiddling with the threads, and I found this out: If I run the
code
> > from the ui thread, like I originally was, the calls to the vm objects
hang.
> > If I run the code from the process thread, the calls work but I can't
add
> > the objects to the UI tree. It complains about locking the object block
from
> > the wrong thread. Next I tried doing everything but the adding children
in
> > the process thread, and sending a message to the application object to
do
> > the children adding. That causes it to kinda work, but the new objects
are
> > unstable and don't always add correctly, or if they do they don't work
right.
>
> This is what I do in Draw, from the process thread, and it works:
>
> @call DPrimary::MSG_GEN_ADD_CHILD( @DTranGroup,
> ( CCF_MARK_DIRTY | TRANSFORM_MENU_POSITION ) );
> @call DTranGroup::MSG_GEN_SET_USABLE(
> VUM_DELAYED_VIA_APP_QUEUE );

Now that I think about it, you're doing something I've never done before.
You're reading in objects from a VM file and trying to attach them to the ui
tree. In my Draw program I'm taking already existing objects (in a separate
resource), slated to run in the ui thread, and attaching them to the ui tree.
In another part of the program I take objects from a VM file and add them to
the "vis" tree that runs in the process thread. And I'm doing the adding from
a method running in the process thread.

The objects being added into the ui tree are in a resource set to run under
the ui thread (ui-object). This is necessary since all the objects in an
object tree must be running in the same thread. For the VM objects that are
being added to the vis tree, they are duplicated from a resource marked as
object (process thread runs them) and attached to the VM file. All the
objects in the vis tree are run by the process thread. This is similar to the
SimpWP sample.

So, to summarize, make sure you've got the VM objects in a resource that is
marked to run in the ui thread (ui-object) if you're going to add them to an
object tree running in the ui thread. It shouldn't matter which thread does
the adding of the objects, at least I don't see why it would.

Hope this helps.

Nathan