A
Ashok K Kumar
Hi all,
Is it alright to write multithreaded addins to Office application? If so,
then what threading model should the threads use (apartment or free)? What is
the best way to access the office objects from the new thread?
I recently wrote an Addin to word application that required to some
operation to be done on a specified timer interval. So I created an object of
the GIT (GlobalInterfaceTable) and registered the Application object
(Word::_Application), created the thread and passed the cookie that got from
the GIT. In the thread worker function, CoInitialized to
COINIT_APARTMENTTHREADED, created the GIT object and used the cookie passed
to get the application object. Everything works fine with the interface
pointer that I got, except when the thread cleans up. When I wanted the
thread to clean up and terminate, I did Application interface->Release() (the
one I got from the GIT). The Thread freezes. If I comment this line, the
CoUninitialize() freezes. First I used the CComPtr, the thread never
terminated and when I examined the thread stack by pausing, the thread frooze
in some call deep under NtDll.dll while trying to Release the Application
Object.
Can some one please explain what could be the problem?
Thanks
Ashok Kumar K
Is it alright to write multithreaded addins to Office application? If so,
then what threading model should the threads use (apartment or free)? What is
the best way to access the office objects from the new thread?
I recently wrote an Addin to word application that required to some
operation to be done on a specified timer interval. So I created an object of
the GIT (GlobalInterfaceTable) and registered the Application object
(Word::_Application), created the thread and passed the cookie that got from
the GIT. In the thread worker function, CoInitialized to
COINIT_APARTMENTTHREADED, created the GIT object and used the cookie passed
to get the application object. Everything works fine with the interface
pointer that I got, except when the thread cleans up. When I wanted the
thread to clean up and terminate, I did Application interface->Release() (the
one I got from the GIT). The Thread freezes. If I comment this line, the
CoUninitialize() freezes. First I used the CComPtr, the thread never
terminated and when I examined the thread stack by pausing, the thread frooze
in some call deep under NtDll.dll while trying to Release the Application
Object.
Can some one please explain what could be the problem?
Thanks
Ashok Kumar K