Posted on 2000-03-20
I need to call a notification function from worker thread, in such a maner that it will run from the main thread. I figured that PostThreadMessage would be the best way. For some reason, PostThreadMessage returns 0, and the function is not being called. Here's my code:
class CDll : public CWinApp
void SyncExecute(void*, LONG);
void AsyncExecute(void*, void*);
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
afx_msg void OnSyncExecute(WPARAM wParam, LPARAM lParam);
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//Adds a function from the main thread to execution queue. Used in order to call notification functions from a worker thread
CDll::SyncExecute(void *address, LONG param)
PostThreadMessage(1272, (WPARAM)address, (LPARAM)param);
//Actualy executes the function
CDll::OnSyncExecute(WPARAM wParam, LPARAM lParam)
NPROC *address = (NPROC*)wParam;
Thanks in advance