MFC 介面卡死到底為何

2021-09-21 13:31:25 字數 1085 閱讀 5850

現象:程式執行一段時間後,介面卡死

程式開啟了乙個監聽執行緒:

//建立接收訊號線程

thread = afxbeginthread(getiomsgthread,

this,

thread_priority_normal,

0,0,

null);

int cfeecard_multidlg::maingetiomsg(lpvoid lpparam)

;int nrecv= 0;

sleep(50);

memset(iobuff,0,256);

nrecv = readcomm(iobuff, 256,hcomm_io);

if (nrecv)

}else if ((iobuff[i] == 0x0d) && (downloadparam[1].goflag == false))//第二個socket

}else if ((iobuff[i] == 0x0b)  && (downloadparam[2].goflag == false))//第三個socket

}else if ((iobuff[i] == 0x07)  && (downloadparam[3].goflag == false))//第四個socket}}

return 0;}

downloadparam[i].hthread = (afxbeginthread(downcosthread, &(downloadparam[i]),thread_priority_normal,0,create_suspended,null))->m_hthread;

int cfeecard_multidlg::downloadcosproc(lpvoid lpparam)

else

if (pdownloadparam->hcomm != null)

}pdownloadparam->goflag = false;

suspendthread(pdownloadparam->hthread);

return 0;

}為何執行一段時間後,介面會出現卡死現象?

解決介面卡死的問題

private void textbox2 textchanged object sender,eventargs e objthread.start 新增以下 忽略控制項多執行緒的安全機制 可實現,但不建議直接建立執行緒操作控制項,控制項上的大多數方法只能從建立控制項的執行緒呼叫 control....

c 介面卡死處理方法

方法一 設定屬性 control.checkforillegalcrossthreadcalls false 開啟乙個新執行緒 thread th new thread search detailid.trim th.isbackground true th.start public void se...

介面卡模式 預設介面卡,類介面卡,物件介面卡

模式思想 改變乙個類的對外介面 增加或減少 以滿足不同外部呼叫者的需求 角色成員 目標介面 target 客戶所期待的介面。目標可以是具體的或抽象的類,也可以是介面。需要適配的類 adaptee 需要適配的類或適配者類。介面卡 adapter 通過包裝乙個需要適配的物件,把原介面轉換成目標介面。適配...