我在辅助线程中定义了两个结构(堆中),运行时一直非正常退出!出错的地方有3个分支,其中有两个分支中都有一个结构,用来作为postmessage的参数。但是有一个运行的很好,另一个运行不下去!百思不得其解 相关代码如下: SAlarmInfo * pAlarmInfo=new SAlarmInfo;
SAlarmInfo * pRemoveAlarmInfo=new SAlarmInfo;
switch(DataInput.DataPack[3+nIndex*7+2])
{
case 0x55: //报警信息
pAlarmInfo->nSensorID=nSensorID;
pAlarmInfo->fltReportValue=fltReportValue;
pAlarmInfo->ctReportTime=ctReportTime;
::PostMessage(pParent->GetSafeHwnd(),WM_ALARM,(WPARAM)pAlarmInfo,NULL);
break; case 0x00:
pRemoveAlarmInfo->nSensorID=nSensorID;
pRemoveAlarmInfo->fltReportValue=fltReportValue;
pRemoveAlarmInfo->ctReportTime=ctReportTime;
pRemoveAlarmInfo->nFlag=2; ::PostMessage(pParent->GetSafeHwnd(),WM_REMOVE_ALARM,(WPARAM)pRemoveAlarmInfo,NULL);
break;
case 0xFF:
......
break;
};
SAlarmInfo * pRemoveAlarmInfo=new SAlarmInfo;
switch(DataInput.DataPack[3+nIndex*7+2])
{
case 0x55: //报警信息
pAlarmInfo->nSensorID=nSensorID;
pAlarmInfo->fltReportValue=fltReportValue;
pAlarmInfo->ctReportTime=ctReportTime;
::PostMessage(pParent->GetSafeHwnd(),WM_ALARM,(WPARAM)pAlarmInfo,NULL);
break; case 0x00:
pRemoveAlarmInfo->nSensorID=nSensorID;
pRemoveAlarmInfo->fltReportValue=fltReportValue;
pRemoveAlarmInfo->ctReportTime=ctReportTime;
pRemoveAlarmInfo->nFlag=2; ::PostMessage(pParent->GetSafeHwnd(),WM_REMOVE_ALARM,(WPARAM)pRemoveAlarmInfo,NULL);
break;
case 0xFF:
......
break;
};
SAlarmInfo * pRemoveAlarmInfo=new SAlarmInfo;
switch(DataInput.DataPack[3+nIndex*7+2])
{
case 0x55: //报警信息 这地方一直走不通!
pAlarmInfo->nSensorID=nSensorID;
pAlarmInfo->fltReportValue=fltReportValue;
pAlarmInfo->ctReportTime=ctReportTime;
::PostMessage(pParent->GetSafeHwnd(),WM_ALARM,(WPARAM)pAlarmInfo,NULL);
break;case 0x00: //这个分支一切正常
pRemoveAlarmInfo->nSensorID=nSensorID;
pRemoveAlarmInfo->fltReportValue=fltReportValue;
pRemoveAlarmInfo->ctReportTime=ctReportTime;
pRemoveAlarmInfo->nFlag=2; ::PostMessage(pParent->GetSafeHwnd(),WM_REMOVE_ALARM,(WPARAM)pRemoveAlarmInfo,NULL);
break;
case 0xFF:
......
break;
};