WIN32 Multithreaded Dll
-
I was wondering if someone could help me out with Multi-threading. I have a Win32 dll that does some heavy scanning and performs callbacks to update a status display of my gui. I introduced multithreading into the DLL and it works fine - but the same callbacks from within the threads fail, and lock up. Outside the threads the callbacks work fine. any ideas or sample examples of Win32 DLL Multithreading (no MFC) Raiden
-
I was wondering if someone could help me out with Multi-threading. I have a Win32 dll that does some heavy scanning and performs callbacks to update a status display of my gui. I introduced multithreading into the DLL and it works fine - but the same callbacks from within the threads fail, and lock up. Outside the threads the callbacks work fine. any ideas or sample examples of Win32 DLL Multithreading (no MFC) Raiden
You're probably doing your screen updates from your threads using
SendMessage
, right? Unfortunately, when you callSendMessage
from a thread that doesn't own the window, it switches threads to make the call. This has the effect of blocking the calling thread. Try doing screen updates usingPostMessage
instead.
Software Zen:
delete this;
-
You're probably doing your screen updates from your threads using
SendMessage
, right? Unfortunately, when you callSendMessage
from a thread that doesn't own the window, it switches threads to make the call. This has the effect of blocking the calling thread. Try doing screen updates usingPostMessage
instead.
Software Zen:
delete this;
Thanks for the reply Garry, I'm actually using callbacks: to return text from the dll to update say a label of the engines location on the gui. dThreadCallBack is a DWORD thats stores the static members address location void StdScanner::CallBackFunction (char *cSomeStringToSend) { typedef int (__stdcall* lpMyCallBack) (LPSTR szMsg); lpMyCallBack MyCallBack; MyCallBack = (lpMyCallBack) dThreadCallBack; MyCallBack(cSomeStringToSend); } Normally this function works perfectly when outside threads, but locks up when I use it in threads. Do you have any examples/source of generic Multithreaded Win32 DLLs (non mfc) that can interact with a gui (be it MFC or WIN32). Raiden
-
I was wondering if someone could help me out with Multi-threading. I have a Win32 dll that does some heavy scanning and performs callbacks to update a status display of my gui. I introduced multithreading into the DLL and it works fine - but the same callbacks from within the threads fail, and lock up. Outside the threads the callbacks work fine. any ideas or sample examples of Win32 DLL Multithreading (no MFC) Raiden
Where is it locking up? If you break into it with the debugger and get a callstack of what's going on when it locks up this would be a big help. Note - When you write a multithreaded program you have to start worrying about the thread safety of every function you call - I suspect this may be your problem. Steve