Hi,
I have declared the interface pointer as a class variable and called CoCreateInstance in thread of that class .
Is there any problem with this way ?
My COM object is based on aparment threading model.
My question is: I am using Single Threaded Apartment , will below mentioned code work ?
Example Code ( Don't go on syntax consider the logic )
Class CClient
{
public:
CClient();
~CClient();
Begin();
IMyInterface* pMyInterface ;
static UINT StartThread(LPVOID pParam);
}
CClient::CClient()
{
CoInitialize(NULL);
}
CClient::~CClient()
{
CoUninitialize(NULL);
}
CClient::Begin()
{
AfxBeginThread(StartThread,(LPVOID)this);
}
CClient::StartThread(LPVOID pParam)
{
CClient*pClient=(CClient*) pParam;
CoCreateInstance(CLSID_MyInterface, NULL,CLSCTX_ALL,
IID_IMyInterface, (void**)(IUnknown**) &pMyInterface );
}
