Background: c # web project called c + + DLL, the DLL encapsulates the network library, useful MFC network database, the function of vc, the other business threads in the DLL using c + + standard library functions, Question: 1. C # call c + + interface function, the parameters for the convenience of the c + + callback callback functions, such as void (F) F this form, now call c + + c # interface is no problem, it was decided that the problem is that if I'm in c + + thread calls the registered callback function with the c + +, c #, if a thread is created using AfxBeginThread function thread c + + program will collapse, I also collapsed, if is to use the standard library STD: : thread created thread wouldn't, solving reason, 2. When close the c # console application, c + + destructors used inside lock function related to the program will crash, prompt netdll. DLL errors, tried a lot of methods are not line, now a temporary solution is in c + + destructors to stop business thread (thread of business is to use STD: : thread created, network thread is to use AfxBeginThread) program after sleep for 5 seconds (3 seconds), the great god help resolve oh,
CodePudding user response:
Generally does not directly open a thread in the DLL, only do calls a method, immediately return a result, Really no exe in open threads, call the DLL method,
1 May is MFC something not initialize 2 way to increase a DLL, stop the DLL which of all, stop and quit
CodePudding user response:
C # delegate, calling convention is that clear
CodePudding user response:
The coupling between managed and unmanaged so tight
CodePudding user response:
Afxbeginthread I remember his thread function is UINT method (LPARAM) form