K
Klaus
Hi,
I have an existing VC 6 MFC application which communicates asynchronly with
a VC 2005 managed code dll.
I use an unmanaged base class with virtual functions to access methods in
the MFC application.
Furthermore, I use a pointer to an unmanaged function to jump back into the
managed dll.
The managed part is basically a remoting enhancement which asynchronly
initiates a call from the remoting thread to the MFC application. The
information is collected within the main thread of the MFC application. The
managed code dll is invoked via a function pointer. From the managed code
additional calls to the unmanaged MFC application will be done via a pointer
to an object in the MFC. When this code is executed within the main thread
of the MFC application everything works fine.
However, if I switch to a MFC worker thread, calls via the base class
pointer results in System.AccessViolationException!
Scenario, which works:
1. Remoting thread imvoked
2. Managed DLL -> MFC App asynchron, no result
3. Switch thread to App main thread
4. MFC App -> Managed DLL
5. Managed DLL -> MFC App (synchron)
Scenario, which does not work:
1. Remoting thread imvoked
2. Managed DLL -> MFC App (asynchron, no result)
3. Switch thread to MFC worker thread!!!
4. MFC App -> Managed DLL
5. Managed DLL -> MFC App (synchron): System.AccessViolationException !!
How can I access pointer to unmanaged classes from managed code within a
worker thread?
Best regards,
Klaus
I have an existing VC 6 MFC application which communicates asynchronly with
a VC 2005 managed code dll.
I use an unmanaged base class with virtual functions to access methods in
the MFC application.
Furthermore, I use a pointer to an unmanaged function to jump back into the
managed dll.
The managed part is basically a remoting enhancement which asynchronly
initiates a call from the remoting thread to the MFC application. The
information is collected within the main thread of the MFC application. The
managed code dll is invoked via a function pointer. From the managed code
additional calls to the unmanaged MFC application will be done via a pointer
to an object in the MFC. When this code is executed within the main thread
of the MFC application everything works fine.
However, if I switch to a MFC worker thread, calls via the base class
pointer results in System.AccessViolationException!
Scenario, which works:
1. Remoting thread imvoked
2. Managed DLL -> MFC App asynchron, no result
3. Switch thread to App main thread
4. MFC App -> Managed DLL
5. Managed DLL -> MFC App (synchron)
Scenario, which does not work:
1. Remoting thread imvoked
2. Managed DLL -> MFC App (asynchron, no result)
3. Switch thread to MFC worker thread!!!
4. MFC App -> Managed DLL
5. Managed DLL -> MFC App (synchron): System.AccessViolationException !!
How can I access pointer to unmanaged classes from managed code within a
worker thread?
Best regards,
Klaus