Re: atl and threads

From: Alexander Nickolov (agnickolov_at_mvps.org)
Date: 03/31/04


Date: Wed, 31 Mar 2004 11:01:31 -0800

I'm afraid I lost you here... You can call CreateWindow[Ex] from
within an interface method of an STA object. Or DialogBox[Indirect]
for that matter (which you know from wrapper classes' DoModal).
In the latter case the dialog spins a modal loop and your method
won't return to the caller until the dialog is dismissed, however
you can call back to the client, and the client can call your object
nested within the modal dialog displaying method call. beyond this,
I don't understand what you are trying to do...

-- 
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@mvps.org
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================
"udo polder" <polder_udo@yahoo.com> wrote in message news:1dbf63f8.0403302312.2071c16@posting.google.com...
> i know i did it wrong thats why i am asking for an hint :)
> and its also important that the VB-activeX dose not do callbacks on
> the com-dll. all i want to do is to open an window of an activeX via a
> interface function (where the name of the function and the activeX
> name is stored in db). and therefore i want to completly separate the
> calling process (c++ ocx) from the resultung activeX (vb-activeX). is
> there some way to do this?
> 
> "Alexander Nickolov" <agnickolov@mvps.org> wrote in message news:<ugzYoToFEHA.3132@TK2MSFTNGP12.phx.gbl>...
> > Sounds like a recipe for disaster. I didn't quite follow your web,
> > but the mere fact you are starting a worker thread is enough
> > to convince me you don't know the rules. VB can only handle
> > single-threaded components. And they should behave themselves
> > too - they can only call back on the same STA thread. Furthermore,
> > an ActiveX Control must be apartment-threaded too, thus all
> > the communication with it happens on the same STA thread.
> > It can internally spin worker threads of course, but they cannot
> > call through direct interface pointers (and after marshaling the
> > call winds up in the control's STA thread anyway). The control
> > is responsible for terminating all threads it started before it
> > unloads. Generally, using worker threads in STA objects is
> > discouraged - it's tricky to do and not a matter for beginners.
> > In your case you don't need it for sure, because a worker thread
> > cannot participate in the shutdown process (it has to be terminated
> > before the shutdown completes).
> > 
> > -- 
> > =========================
> > ============
> > Alexander Nickolov
> > Microsoft MVP [VC], MCSD
> > email: agnickolov@mvps.org
> > MVP VC FAQ: http://www.mvps.org/vcfaq
> > =========================
> > ============


Relevant Pages

  • Re: Thread issue/leak?
    ... > The true thread is doing Interop, the simple example below is not (the ... > simple example produces the error/issue, with or without the STA ... >>>I am creating a worker thread from inside an aspx page and the thread ... >>> window I observe the new thread, but the previous thread is still there ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: GetInterfaceFromGlobal hangs worker thread
    ... the worker thread, because the layout object is already in the STA ... - Back from ILayout::Render to ASP script ...
    (microsoft.public.vc.atl)
  • Re: Cross-apartment COM interface marhsalling
    ... | Is interface marshalling across apartments of a same process handled by ... interface fom the non creating thread/apartment. ... The problem is that STA threads must pump the message queue. ...
    (microsoft.public.dotnet.framework.interop)
  • Problem related to accessing STA server from MTA client
    ... I have a client component operating in an MTA. ... Now I try to access the STA ... component from this worker thread. ... from which the thread was created, or does a new apartment get created? ...
    (microsoft.public.vc.language)
  • Re: How to register TypeLib for DirectShow filter?
    ... attribute marks interface as non-marshallable. ... Secondly i was sort of hoping you might have a suggestion on how to ... Is there a way to force a direct call from an STA ... thread to an MTA object both residing in the same process? ...
    (microsoft.public.win32.programmer.ole)