Sign-up....

我的程序长时间运行就失灵!

由于我的程序需要长时间不断运行,短时间内(1-2小时)程序完全正常,但时间长了(4-6小时)程序会失灵(停止响应)。

主要代码如下,这段代码被反复运行。

Private Sub Timer_Timer()

Dim hDC As Long

hDC = GetDC(0)

If GetPixel(hDC, 1000, 418) = &H39BAFF Then

wait 2

Dim Point As POINTAPI

GetCursorPos Point

Dim a, b

a = Point.X

b = Point.Y

[296 byte] By [msdn] at [2007-8-14 12:06:33]
# 1 Re: 我的程序长时间运行就失灵!

If GetPixel(hDC, 1000, 418) <> &H39BAFF Then GoTo Start_Up

会不会产生死循环?

占用的系统资源可以用任务管理器看一看

csdnnetuser at 2004-10-7 19:54:50 >
# 2 Re: 我的程序长时间运行就失灵!

不会出现死循环!

xionghonge at 2004-10-7 19:56:34 >
# 3 Re: 我的程序长时间运行就失灵!

当软件开启时,CPU占用猛增到100%,怎么办?

xionghonge at 2004-10-7 20:02:41 >
# 4 Re: 我的程序长时间运行就失灵!

短时间可以,长时间不行,是不是时间控件没写好,10001秒的写成了10000秒啊?

xiaoyuanzhi at 2004-10-8 10:27:33 >
# 5 Re: 我的程序长时间运行就失灵!

載屏軟件?

DinoFong at 2004-10-8 11:30:00 >
# 6 Re: 我的程序长时间运行就失灵!

关注,帮你顶!

jam021 at 2004-10-9 14:33:58 >
# 7 Re: 我的程序长时间运行就失灵!

应该是占用了太多的系统资源,所以程序长时间运行会失灵,你检查一下代码中有什么没有释放的,特别是在TIMER中处理的代码.

tztz520 at 2004-10-9 15:51:17 >
# 8 Re: 我的程序长时间运行就失灵!

Private Sub Timer_Timer()

timer1.enabled=False'防止第归进入

.......

.......

timer1.enabled=true

end sub

这样行否?

qiqi5521 at 2004-10-9 16:27:30 >
# 9 Re: 我的程序长时间运行就失灵!

补充一下:

这种情况在子夜前一刻会发生:

假如Timer的最大值是MAX, 而进入Wait的时候, finish=start+X 刚好比Max小一点点, 在开始循环的时候Timer刚好过0了, 于是循环内的start=timer始终是一个小于finish的值了, 嘿嘿!

vodlinux at 2004-10-10 1:40:10 >

VB

All Classified