Click here to Skip to main content
15,905,508 members
Home / Discussions / COM
   

COM

 
QuestionInserting ActiveX control in ActiveX server Pin
ptiJean27-Jun-06 21:44
ptiJean27-Jun-06 21:44 
AnswerRe: Inserting ActiveX control in ActiveX server Pin
Muhammad Azam28-Jun-06 4:18
Muhammad Azam28-Jun-06 4:18 
Questionworking with DLL without it's headers Pin
adidas.levy27-Jun-06 4:23
adidas.levy27-Jun-06 4:23 
AnswerRe: working with DLL without it's headers Pin
Michael Dunn27-Jun-06 6:55
sitebuilderMichael Dunn27-Jun-06 6:55 
AnswerRe: working with DLL without it's headers Pin
User 21559727-Jun-06 9:10
User 21559727-Jun-06 9:10 
GeneralRe: working with DLL without it's headers Pin
adidas.levy27-Jun-06 23:03
adidas.levy27-Jun-06 23:03 
QuestionRunning COM interface method from another thread Pin
shadow0127-Jun-06 0:24
shadow0127-Jun-06 0:24 
AnswerRe: Running COM interface method from another thread Pin
Mike Dimmick27-Jun-06 1:37
Mike Dimmick27-Jun-06 1:37 
You need a marshaller for your COM object - the COM runtime needs to be able to take the parameters for your call and move them to another thread, call the object, then move the return values back to the calling thread.

Firstly, check what sort of object it is. In the registry, under the object's CLSID key, under InprocServer32, you'll see a ThreadingModel value. If this value isn't present at all, the object is single-threaded - calls to it will always run on the first thread in your application, regardless of the thread on which you create the object. If it's 'Apartment', calls to the object will always run on the thread that created it. If it's 'Free', calls to the object will run on the same thread as the caller. If it's 'Both', the behaviour depends on the creating thread: if the creating thread is in a Single Threaded Apartment [STA], it behaves like 'Apartment', but if it's in the Multi-Threaded Apartment [MTA], it behaves like 'Free'.

You can control which apartment each thread lives in. By default in .NET all threads are in the MTA, unless the [STAThread] attribute is used on the thread's start method to force it into the STA. This is done by the WinForms project types on the Main function to make the initial thread an STA thread, for compatibility with ActiveX controls, which must be either not marked or marked 'Apartment'.

IIRC, you still need a marshaller with 'Free' model classes if the creating thread is an STA thread. This marshaller ensures that any events that the class raises (or any other callbacks it makes) come back to the creating thread.

Ideally you probably want to avoid marshalling. If you only want to access the object from a worker thread, create it as needed. Don't create it on the UI thread and keep it around. In fact, if you do create it on the UI thread and it's an Apartment model class, the calls will get marshalled back to the UI thread anyway and still block the UI.

Stability. What an interesting concept. -- Chris Maunder
GeneralRe: Running COM interface method from another thread Pin
shadow0128-Jun-06 0:21
shadow0128-Jun-06 0:21 
QuestionIn Proc COM Server Pin
HakunaMatada26-Jun-06 1:15
HakunaMatada26-Jun-06 1:15 
AnswerRe: In Proc COM Server Pin
Mike Dimmick27-Jun-06 1:57
Mike Dimmick27-Jun-06 1:57 
GeneralRe: In Proc COM Server Pin
HakunaMatada27-Jun-06 18:14
HakunaMatada27-Jun-06 18:14 
QuestionASP and COM Help? Pin
Dave_Roach25-Jun-06 14:42
Dave_Roach25-Jun-06 14:42 
QuestionBreakpoint inside DllMain Pin
Gilly Kumar23-Jun-06 18:18
Gilly Kumar23-Jun-06 18:18 
AnswerRe: Breakpoint inside DllMain Pin
Stephen Hewitt25-Jun-06 13:54
Stephen Hewitt25-Jun-06 13:54 
GeneralRe: Breakpoint inside DllMain Pin
Gilly Kumar26-Jun-06 9:13
Gilly Kumar26-Jun-06 9:13 
QuestionUnable to get IFrames in web page Pin
HarishDixit23-Jun-06 0:28
HarishDixit23-Jun-06 0:28 
AnswerRe: Unable to get IFrames in web page Pin
Michael Dunn23-Jun-06 13:50
sitebuilderMichael Dunn23-Jun-06 13:50 
GeneralRe: Unable to get IFrames in web page Pin
HarishDixit23-Jun-06 20:40
HarishDixit23-Jun-06 20:40 
GeneralRe: Unable to get IFrames in web page Pin
Michael Dunn23-Jun-06 22:13
sitebuilderMichael Dunn23-Jun-06 22:13 
GeneralRe: Unable to get IFrames in web page Pin
HarishDixit24-Jun-06 1:04
HarishDixit24-Jun-06 1:04 
QuestionHow to forbid the context menu in mshtml editor? Pin
dreamwinter21-Jun-06 22:22
dreamwinter21-Jun-06 22:22 
QuestionWindows Management Instry\umentation Pin
abhiramsss21-Jun-06 19:48
abhiramsss21-Jun-06 19:48 
QuestionWindows Management Instry\umentation] Pin
abhiramsss21-Jun-06 19:48
abhiramsss21-Jun-06 19:48 
QuestionDLL Technology Pin
Logan from Singapore20-Jun-06 21:24
Logan from Singapore20-Jun-06 21:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.