Help!! - "both" components
-
I have been running around in circles trying to find comprehensive guidelines and examples on how to write "both" components, the msdn site is totally#$#$# up. Can someone give me some guidelines and point me to some articels/samples? thanks a heap:) Man Learns from History that he never learns from History
-
I have been running around in circles trying to find comprehensive guidelines and examples on how to write "both" components, the msdn site is totally#$#$# up. Can someone give me some guidelines and point me to some articels/samples? thanks a heap:) Man Learns from History that he never learns from History
Could you be a little more descriptive in what you mean by "both" components. - Nick Parker
My Blog -
Could you be a little more descriptive in what you mean by "both" components. - Nick Parker
My BlogTrying to write an in-process component whose threading model will be "both". I want it to be instantiated in the same apartment as the client, irrespective of whether the client has entered an STA or MTA. If I understand right, the main criteria for writing this kind of component pertains to how I can perform callbacks to the client. thanks Man Learns from History that he never learns from History
-
Trying to write an in-process component whose threading model will be "both". I want it to be instantiated in the same apartment as the client, irrespective of whether the client has entered an STA or MTA. If I understand right, the main criteria for writing this kind of component pertains to how I can perform callbacks to the client. thanks Man Learns from History that he never learns from History
-
That's right. If your component might use the client object on the thread other than STA (if the client is in STA), you'd have to do marshalling/unmarshalling of the client object "manually". Edward
So would this work? When I decide I need to do a callback, I check the thread id of the current thread. If it matches the one that passed the callback pointer(which I would have stored somewhere), I make a direct call. If not, I call it via a proxy which I implement with custom marshalling. BTW, if I dont use callbacks in the component, can I go ahead and implement it as "both" without worrying about anything else? thanks!! Man Learns from History that he never learns from History
-
So would this work? When I decide I need to do a callback, I check the thread id of the current thread. If it matches the one that passed the callback pointer(which I would have stored somewhere), I make a direct call. If not, I call it via a proxy which I implement with custom marshalling. BTW, if I dont use callbacks in the component, can I go ahead and implement it as "both" without worrying about anything else? thanks!! Man Learns from History that he never learns from History
I wouldn't bother with checking threadid, you rcomponent might be called from MTA. If your object pointer is not being passed directly to another thread (for instance one of object's methods created thread and from this thread you invoke one of the objects methods) you do not have to worry about this at all. And you are right, if you do not use other objects (callbacks or internally created com objects) in your component you don't have to worry about all this (of course synchronization must be taken care of). As for marshalling, in case it's necessary, I usually prefer using GIT (global interface table, works on NT sp3, Win95 with dcom): for instance when object gets created I'd register it in the GIT (IGlobalInterfaceTable::RegisterInterfaceInGlobal) and then all other threads that need to use the object would get the interface pointer from GIT (GetInterfaceFromGlobal) instead of using it directly, this way none the object itself can use any internal com objects (callbacks) safely. HTH, Edward
-
I wouldn't bother with checking threadid, you rcomponent might be called from MTA. If your object pointer is not being passed directly to another thread (for instance one of object's methods created thread and from this thread you invoke one of the objects methods) you do not have to worry about this at all. And you are right, if you do not use other objects (callbacks or internally created com objects) in your component you don't have to worry about all this (of course synchronization must be taken care of). As for marshalling, in case it's necessary, I usually prefer using GIT (global interface table, works on NT sp3, Win95 with dcom): for instance when object gets created I'd register it in the GIT (IGlobalInterfaceTable::RegisterInterfaceInGlobal) and then all other threads that need to use the object would get the interface pointer from GIT (GetInterfaceFromGlobal) instead of using it directly, this way none the object itself can use any internal com objects (callbacks) safely. HTH, Edward
So we do not need "custom" marshalling here, only "manual" invocation of the facilities already available. When the component gets the interface pointer to the callback object, it checks it into the GIT. When the client needs to be notified of something, the interface pointer is checked out from the GIT and the callback performed. thanks Steve