Well, I will answer this myself
This can be done in 3 ways actually. one way I will brief.
using the CComGitPtr from atlbase.h
Do like this :
CComGitPtr
GitPtrName (pointer to the initialized
interface)
Now extract the cookie from the DWORD dwCokie = GitPtrName->Detach();
Now pass the cookie as a content of struct(optional) inside the worker thread.
Once you are inside the worker thread, extract the cookie, call CoInitilize, and instantiate the reqiuired interface pointer.
as COMInterfacethatneedMarshalling pReqd.
Now pass the git cookie to the GI table and retrieve the marshalled COM object.
like:
// This is done inide the thread
// retrieve the passed cookie as dwCookie
CComGITPtr<COMInterfacethatneedMarshalling
pToGITTest(dwCookie);
COMInterfacethatneedMarshalling pReqd;
pToGITTest.CopyTo(&pReqd);
Now we have pToGITTest inside the thread, fully marshalled, go ahead and enjoy!
Thanks.