In handling a COM event from the out-of-proc server, the app calls a method
on an in-proc server. This method executes more slowly when called from the
event handler than it does if called from the app's primary thread. I
(affiliated with an MTA) was using a COM object created in a STA. Creating
"Willy Denoyette [MVP]" <willy.denoyette@telenet.be> wrote in message
news:esjVZ7wrFHA.1252@TK2MSFTNGP09.phx.gbl...
> I'm missing something here, you are talking about an out-proc COM server,
> in this scenario there is no cross-apartment marshaling involved, all
> there is is cross-process marshaling over DCOM which is allways much
> slower than in-proc marshaling between incompatible apartments.
> Question is what out-proc server are you talking about? Is this a VB6
> ActiveX server?
>
> Willy.
>
> "George" <geobier@newsgroup.nospam> wrote in message
> news:euTOpEcrFHA.3068@TK2MSFTNGP14.phx.gbl...
>> Thanks for the explanation. Switching to the primary thread to handle
>> the event solved the original problem, which was slow execution on
>> in-proc, apartment-threaded COM server methods. (Roughly 80 times faster
>> on the primary thread!)
>>
>> Thinking that cross-apartment marshaling was responsible, I changed the
>> in-proc server to the free-threaded model, but the timings didn't
>> improve. Was cross-apartment marshaling a bad theory or is .NET/COM
>> Interop somehow affecting this? Thanks again for the help.
>>
>>
>> "Jared Parsons [MSFT]" <jaredpar@online.microsoft.com> wrote in message
>> news:%23cuSvsOrFHA.304@TK2MSFTNGP11.phx.gbl...
>>> This is one major difference between VB6 and .NET. In VB6 all of the
>>> objects you create are STA COM objects. This is what caused the events
>>> to be marshaled back to the primary thread. .NET objects have no
>>> concept of thread affinitiy [1]. The best way to view a .NET object is
>>> that it is a MTA object that aggregates the free threaded marshaller,
>>> (or that it lives in the thread nuetral apartment).
>>>
>>> You will have to manually Marshal these events back to the foreground
>>> thread.
>>>
>>> [1] Technically ContextBound objects do have a concept of thread
>>> affinity but that's not relevant in this scenario.
>>>
>>> --
>>> Jared Parsons [MSFT]
>>> jaredpar@online.microsoft.com
>>>
http://blogs.msdn.com/jaredpar >>> "This posting is provided "AS IS" with no warranties, and confers no
>>> rights"
>>> "George" <geobier@newsgroup.nospam> wrote in message
>>> news:u07B$UOrFHA.332@tk2msftngp13.phx.gbl...
>>>> My .NET application handles events from an out-of-proc COM server.
>>>> These
>>>> events do not execute on the app's primary thread, however. Is this a
>>>> consequence of COM Interop or can this be controlled? (The .NET app is
>>>> configured to run in a STA.) In a VB6 program, the events are executed
>>>> on
>>>> the primary thread. Thanks for the help.
>>>>
>>>>
>>>
>>>
>>
>>
>
>