<jl******@gmail.com> wrote in message
news:11*********************@v46g2000cwv.googlegro ups.com...
|I was wondering if there was a utility that could tell you when your C#
| application is making cross-apartment COM calls. I have a fairly large
| application that makes extensive use of a 3rd party object system that
| is exposed to .NET through COM, and I'm really trying to avoid slow
| cross-apartment calls.
|
No, there is no such a 'utility', if you want to prevent any
cross-apartment- cross-thread calls you have to make sure your COM objects
live in a 'compatible' apartment and that you access the object from the
creators thread only.
| Also, is using Invoke() on a class created from the main thread a
| solution to making COM calls into that thread?
|
If you mean Control,Invoke, the answer is no, this method is meant to
dispatch delegates to the UI thread, this has nothing to do with
cross-thread COM calls.
The CLR will automagically marshal the Interface pointer when calling a COM
method using an object reference (a RCW) from another thread as the
creator's thread, so you don't hav to take care of this.
Willy.