关于多线程的疑惑...
刚刚在前一个帖子里学到了adlib..觉得很好用.然后忽然看到我的记事本自动保存的文件证在被杀毒软件疯狂的扫描..每秒钟扫描N多次..我那个汗啊...因为每几十毫秒就自动保存一次...(不保存也会读取一下.一样被杀毒软件逮到)于是就准备把自动保存的部分分离出来,弄个adlib,每1min保存一次
然后发现记事本的作者已经用了一个adlib.毫无疑问..adlib只能用一次...
然后我就搜索到了这个帖子...这个帖子里的五楼说的计时器.跟adlib类似吗?
还搜索到这个大牛的帖子..可惜没看懂这个多线程是怎么实现的...不过效果似乎达成了... AdlibRegister Adlib不是多线程 如果只要简单的重复动作 就用Adlib好了
3.3.1.0以上 改为AdlibRegister 了可以用多个 相当于 定时器了 楼上理解错了
lou楼主,我上次说的减法就能解决你的问题
但要是你不想,可以
$Timer = DllCallbackRegister("Timer", "int", "hwnd;uint;uint;dword")
$TimerDLL = DllCall("user32.dll", "uint", "SetTimer", "hwnd", 0, "uint", 0, "int", 5000,"ptr", DllCallbackGetPtr($Timer))
$Timer2 = DllCallbackRegister("Timer", "int", "hwnd;uint;uint;dword")
$Timer2DLL = DllCall("user32.dll", "uint", "SetTimer", "hwnd", 0, "uint", 0, "int", 8000, "ptr", DllCallbackGetPtr($Timer2))
$Timer3 = DllCallbackRegister("Timer", "int", "hwnd;uint;uint;dword")
$Timer3DLL = DllCall("user32.dll", "uint", "SetTimer", "hwnd", 0, "uint", 0, "int", 10000, "ptr", DllCallbackGetPtr($Timer3))
While 1
GUIGetMsg()
WEnd
Func Timer($hWnd, $uiMsg, $idEvent, $dwTime)
If $idEvent = $TimerDLL Then
MsgBox(0,"","线程1")
ElseIf $idEvent = $Timer2DLL Then
MsgBox(0,"","线程2")
ElseIf $idEvent = $Timer3DLL Then
MsgBox(0,"","线程3")
EndIf
EndFunc
红色字就是毫秒 某段源码
GUISetState(@SW_SHOW)
AdlibEnable("_abc",50)
$Timer = DllCallbackRegister("Timer", "int", "hwnd;uint;uint;dword")
$TimerDLL = DllCall("user32.dll", "uint", "SetTimer", "hwnd", 0, "uint", 0, "int", 999, "ptr", DllCallbackGetPtr($Timer))
Func _nowdate()
Local $now = " 现在是:"&@HOUR&":"&@MIN&":"&@SEC
GUICtrlSetData($data,$now)
EndFunc
Func Timer($hWnd, $uiMsg, $idEvent, $dwTime)
If $idEvent = $TimerDLL Then _nowdate()
EndFunc 我明白了~~我换新版去..{:3_92:}
我也知道不是多线程...但是差不多实现了那个功能.. 囧 我觉得新版的AdlibRegister和timer在应用层上 没啥区别了 不过adlib要方便很多...
页:
[1]