Event firing inside a Thread ?? 
Author Message
 Event firing inside a Thread ??

Hi

I have wtitte a simple ATL DLL which can fire events. When a methed a
called, my event fires. This step is working fine. I want to make the
following changes to my ATL. When a Method called, a thread will be created
and in that thread I want to trigger my event. To do so, I have to pass the
current COM context(this) to tyhe thread.

I want to know how to pass the current context (this) to the thread. I
checked the MSDN, they say to pass as followo

this is in the method

m_hThread = ::CreateThread( NULL,  0,
(LPTHREAD_START_ROUTINE)&CUrlReader::ProcessUrl,  this,
                                                0, &m_dwThreadId);

thisd is inside the thread function

DWORD WINAPI CUrlReader::ProcessUrl(void * pParam)
{
   CUrlReader * pCaller = (CUrlReader *)pParam;
   pCaller->Fire_ReadUrlFinished(0);
   return

Quote:
}

but this doesn't work.. it crashes in the pCaller->Fire_ReadUrlFinished(0);
Can some one help on this ?

Vijayaratnam Ganeshkumar

http://www.*-*-*.com/



Fri, 04 Jun 2004 12:01:02 GMT  
 Event firing inside a Thread ??
take a look at

http://support.microsoft.com/default.aspx?scid=kb;EN-US;q280512


Quote:
> Hi

> I have wtitte a simple ATL DLL which can fire events. When a methed a
> called, my event fires. This step is working fine. I want to make the
> following changes to my ATL. When a Method called, a thread will be
created
> and in that thread I want to trigger my event. To do so, I have to pass
the
> current COM context(this) to tyhe thread.

> I want to know how to pass the current context (this) to the thread. I
> checked the MSDN, they say to pass as followo

> this is in the method

> m_hThread = ::CreateThread( NULL,  0,
> (LPTHREAD_START_ROUTINE)&CUrlReader::ProcessUrl,  this,
>                                                 0, &m_dwThreadId);

> thisd is inside the thread function

> DWORD WINAPI CUrlReader::ProcessUrl(void * pParam)
> {
>    CUrlReader * pCaller = (CUrlReader *)pParam;
>    pCaller->Fire_ReadUrlFinished(0);
>    return
> }

> but this doesn't work.. it crashes in the

pCaller->Fire_ReadUrlFinished(0);

- Show quoted text -

Quote:
> Can some one help on this ?

> Vijayaratnam Ganeshkumar

> http://www.mediasolv.com/gk



Fri, 04 Jun 2004 13:58:20 GMT  
 Event firing inside a Thread ??
See http://www.mvps.org/vcfaq/com/1.htm
--
With best wishes,
    Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken


Quote:
> Hi

> I have wtitte a simple ATL DLL which can fire events. When a methed a
> called, my event fires. This step is working fine. I want to make the
> following changes to my ATL. When a Method called, a thread will be
created
> and in that thread I want to trigger my event. To do so, I have to
pass the
> current COM context(this) to tyhe thread.

> I want to know how to pass the current context (this) to the thread. I
> checked the MSDN, they say to pass as followo

> this is in the method

> m_hThread = ::CreateThread( NULL,  0,
> (LPTHREAD_START_ROUTINE)&CUrlReader::ProcessUrl,  this,
>                                                 0, &m_dwThreadId);

> thisd is inside the thread function

> DWORD WINAPI CUrlReader::ProcessUrl(void * pParam)
> {
>    CUrlReader * pCaller = (CUrlReader *)pParam;
>    pCaller->Fire_ReadUrlFinished(0);
>    return
> }

> but this doesn't work.. it crashes in the

pCaller->Fire_ReadUrlFinished(0);

- Show quoted text -

Quote:
> Can some one help on this ?

> Vijayaratnam Ganeshkumar

> http://www.mediasolv.com/gk



Sat, 05 Jun 2004 04:07:43 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Firing ATL event inside thread??

2. Firing events from inside a Repeater?

3. firing events from second thread

4. Firing events from a worker thread

5. How to serialized events fired from a secondary thread

6. Firing events from worker threads

7. Fire Events from Thread Pool

8. help firing event from thread

9. Firing Events from a different thread

10. Creating threads and firing events in COM!

11. fire event in second thread does not work in MinDependency

12. Connection Pionts Event firing in worker thread

 

 
Powered by phpBB® Forum Software