
VB6 Guru needed: VB6 Multithreaded ActiveX exe and Typelibs
Good day,
I have a question for a Visual Basic/ActiveX guru.
Thank you in advance for your help.
I'm developping an ActiveX exe with VB6 to perform asynchronous operations.
I have read roundabout 20 times "building code components" in my MSDN to
understand the circular references,
correct thread creation and destruction, call backs and so on. I have
eventualy made a fully operational multithread
VB component and it runs fine.
The component contains two classes designed to run in two different threads
(instancing property set to MultiUse)
* The first class InterfClass contains all the operations the component's
user is able to do, it also
contains a number of events to report errors and completions.
* The second class IOClass contains the actual monitoring of system events
using the WaitForMultipleObjects API.
the ioclass object is created by the interfclass object during its
initialization.
It also has a class DefsClass, defined as PublicNotCreatable used to store
constants for the programmer's use.
So what's the problem?
I don't want the component users to be confused by the IOClass, I want them
to be able to create the
InterfClass only, IOClass doing its job as a "backgroung thread" hidden to
the programmer.
Problem #1: If I want to hide the IOClass in the Typelib, I have to set the
instancing property to "Private".
This causes a problem when using CreateObject (because the class is not in
the typelib)
Problem #2: If I use New instead of CreateObject to create IOClass, the
object creation is ok,
but it is created in the InterfClass thread. Thus I lose the
multithreading capability.
Related Problems:
InterfClass ans IOClass need to exchange information. In a VB 6.0
multithreaded environment,
only Public Functions, Subs and Properties can do this.
This makes them visible in the typelib, however they should be "Friend" and
not appear in the typelib.
Q1: Is there a way to hide the IOClass in the Typelib and still being able
to start a new thread when I create
an IOClass object from inside my component?
Q2: Is there a way (besides a friend declaration) to hide some InterfClass
functions and still being able to call
them from the IOClass object?
Thank you for your help.
--------------------------------------------------------------------
Marc PERSONENI
Cipango Pty Ltd Australia
-------------------------------------------------------------------