tags:

views:

76

answers:

1

Hi,

I'm trying to create COM component, where it will be frequently call by a excel application (excel will load the COM at its initialization) and another process (let say procA) also sends (with high frequency) windows messages to this component. Currently I implemented COM as a STA, however, I experienced that while COM is busy with processing messages from procA, the excel UI get stuck.

Please help me to get around this problem. Can I just create a simple window thread to process messages from procA while keeping COM as STA model ? Or do I need to make COM as MTA model, if so please explain how to handle it .

Thank You

+1  A: 
Richard
Thank you for your explanation, If I'm correct you'r telling me that I have to use MTA to fulfill my requirement and Neural model would be a better choice. Please correct me if I'm wrong.I'm not familiar with creating threads inside COM, Is it just windows thread that we use in c++ application ? Please explain or give me a reference.My Plan is to create two threads T1, T2. T1 will process messages from procA and update a global object. And T2 will also access this Global object as Excel query to update values.So Global Object must be locked. Will this model be ok ?
Nimo
@Nimo: Yes: if you were thinking about threading model of "Free", then "Neutral" is almost always a better option. Generally components do not create threads themselves (clients or COM runtime do). If you need a worker thread you need to ensure you manage it fully, not just initialising it for COM, but also all the typical problems of a library spinning up a thread (e.g. handling COM unloading your dll).
Richard