dqh
Mar 5th, 2002, 10:51 AM
Does anyone know how to implement VB call backs from a C++ DLL when the DLL operates in a seperate Thread to the VB executable?
I have a VB program which calls a function in a C++ DLL which then awaits network activity. It does this in a Thread it creates for itself, before returning control to the VB front-end (to allow the GUI to remain responsive while the network is being monitored). When network activity begins the C++ dll Calls a VB function to notify the front end - it does this using a function pointer given to it by the VB AdressOf operator.
Within the VB development environment this works OK, but when it is built into a .exe the program crashes as the C++ dll "calls back." This happens everytime, without fail. It even occurs if the body of the VB function is completely empty, i.e. there are definately no concurrent access issues etc..., VB just doesn't allow the DLL access to its functions! If the call back operates within the same Thread of Execution (i.e. instead of the DLL running in its own Thread it blocks the GUI whilst waiting for network activity) it works fine.
Does anyone know how I can solve this?
Thanks,
Dave.
I have a VB program which calls a function in a C++ DLL which then awaits network activity. It does this in a Thread it creates for itself, before returning control to the VB front-end (to allow the GUI to remain responsive while the network is being monitored). When network activity begins the C++ dll Calls a VB function to notify the front end - it does this using a function pointer given to it by the VB AdressOf operator.
Within the VB development environment this works OK, but when it is built into a .exe the program crashes as the C++ dll "calls back." This happens everytime, without fail. It even occurs if the body of the VB function is completely empty, i.e. there are definately no concurrent access issues etc..., VB just doesn't allow the DLL access to its functions! If the call back operates within the same Thread of Execution (i.e. instead of the DLL running in its own Thread it blocks the GUI whilst waiting for network activity) it works fine.
Does anyone know how I can solve this?
Thanks,
Dave.