Re: COM and VB
"Zf" <Zf@discussions.microsoft.com> wrote in message
news:3B03B696-66F0-42AB-B281-55E5D2EECD43@microsoft.com
In the original implementation, the function in COM object called
from VB will pass the object itself to the new thread. Then in the
thread, the passed in object does the real work. This works in VB5
and VC97, but it crashes with a COM object implemented with VB.
Yes, VB6 is not thread safe. As far as I know, there's no way to have VB
code, whether packaged as COM object or otherwise, run safely on any
thread other than the main one.
Marshalling a COM interface pointer to the worker thread is quite
pointless in this scenario. Realize that any call from the worker
through such a marshalled pointer is transferred right back to the main
thread, executed there, and any results transferred back to the worker.
That's why your UI appears frozen - the main UI thread is busy executing
COM method. The worker thread doesn't actually do any work, but spends
all its time waiting for the main thread to return from a COM call.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925