problem with CreateThread in the InProc server. 
Author Message
 problem with CreateThread in the InProc server.

I am creating a Inproc com object.
The object is supposed to multiple threads.
I use CreateThread for creating thread.
Each thread has a correspondinf event.
I am new to Multi threading & my code would reflect that.
I have the following questions.
1) Why should one not use WaitForSingleobject in the ThreadProc.
2) Would it work if WaitForSingleObejct is replace by
AtlWaitWithMessageLoop.
3) Is it a bad idea to have multiple thread in an inrpoc component.
I am attaching the code, please all gurus guide me.
Function to create threads.
BOOL CSendMail::Initialize()
{
    for (int i = 0; i < m_lThreads; i++)
     {
      pSession[i].m_pObj = this;
      pSession[i].m_hEvent = CreateEvent(NULL, FALSE, FALSE, "");
      pSession[i].m_hThread = CreateThread(NULL, 0, &DeliveryThreadProc,
&pSession[i],
        0, &pSession[i].m_lThreadID );
 }
The non-working threadProc
DWORD WINAPI DeliveryThreadProc(void* pv)
{
 CSendMail::SessionData* pS = (CSendMail::SessionData*)pv;
 CSendMail* pObj = pS->m_pObj;
HRESULT hr = CoInitialize(NULL);
 while (AtlWaitWithMessageLoop( pS->m_hEvent)) // The thread exist with a
status code of 0.
 {
      pObj->ProcessData(pS->m_hEvent);
 }
CoUninitialize();
 CloseHandle(pS->m_hThread);
 return 0;

Quote:
}



Sun, 04 May 2003 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Use of CreateThread in a InProc COM object, ThreadProc doesn't work

2. InProc Server (Marshalling problem)

3. Starting an inproc server as a local server using a DLL Surrogate

4. Basic questions about CLSCTX enum, inproc and out-of-proc servers

5. registering ATL inproc server

6. Inproc Server loading Java HotSpot DLL

7. Registering in the ROT an ActiveX object implemented in an inproc server

8. Remote Debugging An Inproc Server

9. * export enums from ATL inproc server to clients

10. Quesion on Loadlibrary in an Inproc Server...

11. Inproc automation server with multiple interfaces

12. URGENT:CoCreateInstanceLic fail in inproc server.

 

 
Powered by phpBB® Forum Software