المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Raise thread safe event



C++ Programming
04-03-2009, 12:02 AM
I have a rountine in an ActiveX control that is called from another thread (made by some other DLL). I want to be able to raise an event ('Error' in this case which takes a long and a string as argument) which will be caught by the VB6 app which will contain this ActiveX control. Unless I'm mistaken, the reason my VB6 app keeps crashing is because I'm not performing any kind of thread safety. Can someone please let me know what I should be doing here (or if my assumption is wrong)?


void __stdcall MyActiveXCtrl::OnReplyAudio(LPVOID pData)
{
if (CAN_PLAY_AUDIO)
{
ProcessAudio(pData);

//this next line calls a DLL which will in turn call this rountine again
if (!m_audioHardware->RequestAudio())
Error(23, _T("m_audioHardware->RequestAudio()=FALSE"));
}
else
UnloadAudio();
}