关于3个for循环的问题!~
本帖最后由 cutyourchicken 于 2011-2-16 03:33 编辑3个for循环嵌套,会大量占用CPU,有什么办法解决吗?Func UpdateDat()
$Mlistcount=_GUICtrlListView_GetItemCount(GUICtrlGetHandle($listview1))
Dim $array[$count][$sub]
For $i = 0 To $count - 1
For $x = 0 To $sub - 1
$array[$i][$x] = ControlListView($handle, '', $ctrl, 'GetText', $i, $x)
If $array[$i]<> "" Then
$Info= "X..." Else
If $array[$i] == "" Then
$Info= "Y..."
Else
$Info= "Z..."
EndIf
EndIf
For $bi = 0 To $Mlistcount-1
If _GUICtrlListView_GetItemText(GUICtrlGetHandle($listview1),$bi,0)==StringTrimLeft($array[$i],1) Then
_GUICtrlListView_SetItemText($listview1,$bi,$array[$i],1)
_GUICtrlListView_SetItemText($listview1,$bi,$array[$i],2)
_GUICtrlListView_SetItemText($listview1,$bi,$array[$i],3)
_GUICtrlListView_SetItemText($listview1,$bi,$Info,4)
ExitLoop
EndIf
Next
Next
Next
EndFunc
不好意思,代码排得比较乱,改了一下了 延迟一下就好。 Func UpdateDat()
$Mlistcount=_GUICtrlListView_GetItemCount(GUICtrlGetHandle($listview1))
Dim $array[$count][$sub]
For $i = 0 To $count - 1
For $x = 0 To $sub - 1
$array[$i][$x] = ControlListView($handle, '', $ctrl, 'GetText', $i, $x)
If $array[$i]<> "" Then
$Info= "X..." Else
If $array[$i] == "" Then
$Info= "Y..."
Else
$Info= "Z..."
EndIf
EndIf
For $bi = 0 To $Mlistcount-1
If _GUICtrlListView_GetItemText(GUICtrlGetHandle($listview1),$bi,0)==StringTrimLeft($array[$i],1) Then
_GUICtrlListView_SetItemText($listview1,$bi,$array[$i],1)
_GUICtrlListView_SetItemText($listview1,$bi,$array[$i],2)
_GUICtrlListView_SetItemText($listview1,$bi,$array[$i],3)
_GUICtrlListView_SetItemText($listview1,$bi,$Info,4)
ExitLoop
EndIf
_ winapi_emptyworkingset()
Next
_ winapi_emptyworkingset()
Next
_ winapi_emptyworkingset()
Next
EndFunc
本帖最后由 cutyourchicken 于 2011-2-16 13:56 编辑
回复 3# netegg
测试过了,还是没有什么效果!~还是和以前一样,卡GUI 回复 2# 风雨网络
延时了一下,的确有效果,不过还是会卡GUI 回复 4# cutyourchicken
那段只是为了资源占用的事,你又没问卡不卡的事 把gui界面也写出来,这样可以直接实行,这样别人也愿意帮你.
找问题也好找,没头没尾的代码是很费力的. 感覺應該是刷新問題(指在gui模式時)
搭配個暫停刷新顯示即可
页:
[1]