BOOL CVfpocxCtrl::setMonitor() { int iRet = SXERR_FAIL; iRet = SXInit( SX_COMPACT_MESSAGING , NULL ); //If its OK then show the about dialog if ( iRet != SX_OK ) { MessageBox( NULL , "SXInit returned NOT OK " ) ;} iRet = SXERR_FAIL; char charPBXIPAddress[40]; strcpy( charPBXIPAddress , m_cPBXIpAddress ); iRet = SXOpenPBX(SX_PBX_HANDLE_PTR, &hPBXObject , SX_PBX_IPADDRESS, charPBXIPAddress, SX_COMMS_ERROR_PROC, this->callBackMitaiEvent, SX_COMMS_ERROR_DATA_PTR, this, NULL); this->setErrorText(iRet) ; if (iRet != SX_OK) { return false ; } iRet = SXMonitor ( &hMonitorHandle , SX_PBX_HANDLE, hPBXObject , SX_DN, (LPCTSTR)m_cDNofExtensionToMonitor , NULL ); this->setErrorText(iRet) ; if (iRet != SX_OK) { return false ; } iRet = SXSetCallback(SX_MONITOR_HANDLE, hMonitorHandle , SX_EVENT , OnCallReceived , SX_CALLBACK_PROC, this->callBackMitaiOnCallReceived , SX_CALLBACK_DATA_PTR , this , NULL); }this callback is also a member function of this class and I have the evnet firing in a new thread, is this enough protection or should the setMonitor member function be launched in a new thread ?
void CVfpocxCtrl::callBackMitaiOnCallReceived(SXEvent* pEvent , CVfpocxCtrl* pThis) { int event_type = SX_EventType(pEvent); char* event_name = SXGetText ( SX_EVENT, event_type, NULL ) ; char* state_name = SXGetText ( SX_STATE, SX_EventState(pEvent), NULL ) ; char* cause_name = SXGetText ( SX_CALL_CAUSE, SX_EventCause(pEvent), NULL ) ; pThis->m_sxCallsInternalID = SX_EventCallId(pEvent); // Now the Caller device SXDevice * oDevice = SX_CallerDevice(pEvent) ; pThis->m_cCallerIDName = SX_GetName(SX_DeviceName(oDevice)) ; pThis->m_cCallerIDFirstName = SX_GetFirstName(SX_DeviceName(oDevice)) ; pThis->m_cCallerIDMiddleName = SX_GetMiddleName(SX_DeviceName(oDevice)) ; pThis->m_cCallerIDLastName = SX_GetLastName(SX_DeviceName(oDevice)) ; SXDigits * cDNIS = SX_DeviceDNIS(oDevice) ; SXNumber * cANI = SX_DeviceANI(oDevice) ; pThis->m_cDNISDigits = cDNIS->digits ; pThis->m_cAniDigits = cANI->number ; pThis->m_cMitaiEventCause = cause_name ; pThis->m_cMitaiEventName = event_name ; pThis->m_cMitaiEventState = state_name ; //Fire the event //pThis->FireMitaiEvent() ; // AfxBeginThread( fireTheMiTAiEvent , pThis); AfxBeginThread(fireTheMiTAiEvent,pThis,THREAD_PRIORITY_NORMAL,0,0,NULL); }Thanks !