具有计时器要求的子程序 [英] subroutine with timer requirement
问题描述
我有一个sub需要做一些事情然后等待指定长度的
时间再继续。我尝试在其tick事件中添加一个带计数器的计时器
然后检查子程序中的计数器状态。但这并不是
工作:
单身进度模糊
Sub mysub
stuff
timer1.enabled = true
进度时< 1
textbox1.text = progress
结束更多的东西
end sub
timer1 tick事件处理程序
进度=进度+.01
结束
文本框显示我没有发生任何事情。程序挂断了。
这样做的正确方法是什么?这应该是一个线程应用吗?
-
mark
I have a sub which needs to do some things then wait a specified length of
time before going on. I tried adding a timer with counter in its tick event
then checking the state of the counter in the subprocedure. But this doesn''t
work:
dim progress as single
Sub mysub
stuff
timer1.enabled = true
while progress <1
textbox1.text=progress
end while
more stuff
end sub
timer1 tick event handler
progress = progress +.01
end
The textbox shows me that nothing is happening. The program hangs up.
What''s the right way to do this? Should this be a threading application?
--
mark
推荐答案
尝试这样的事情。
timer1.enabled = true
more东西
end sub
timer1 tick事件处理程序
progress = progress +.01
textbox1 .text = progress.tostring
timer1.enabled =进度< 1
结束
肯
--- ---------------------
" mark" <毫安** @ discussions.microsoft.com>在留言中写道
新闻:0C ********************************** @ microsof t.com ...
我有一个子需要做一些事情然后等待指定长度的
时间再继续。我尝试在其tick事件中添加一个带计数器的计时器
然后检查子程序中的计数器状态。但这并不是
工作:
单身进度模糊
Sub mysub
stuff
timer1.enabled = true
进度时< 1
textbox1.text = progress
结束更多的东西
end sub
timer1 tick事件处理程序
进度=进度+.01
结束
文本框显示我没有发生任何事情。程序挂断了。
这样做的正确方法是什么?这应该是一个线程应用程序吗?
-
mark
Hi,
Try something like this.
timer1.enabled = true
more stuff
end sub
timer1 tick event handler
progress = progress +.01
textbox1.text=progress.tostring
timer1.enabled = progress<1
end
Ken
------------------------
"mark" <ma**@discussions.microsoft.com> wrote in message
news:0C**********************************@microsof t.com...
I have a sub which needs to do some things then wait a specified length of
time before going on. I tried adding a timer with counter in its tick event
then checking the state of the counter in the subprocedure. But this doesn''t
work:
dim progress as single
Sub mysub
stuff
timer1.enabled = true
while progress <1
textbox1.text=progress
end while
more stuff
end sub
timer1 tick event handler
progress = progress +.01
end
The textbox shows me that nothing is happening. The program hangs up.
What''s the right way to do this? Should this be a threading application?
--
mark
可以你不只是使用While循环与DateTime.Now等待某个
秒数?
" mark"写道:
Can you not just use a While loop with the DateTime.Now to wait a certain
number of seconds?
"mark" wrote:
我有一个子需要做一些事情然后等待指定长度的时间才能继续。我尝试在其勾选事件中添加一个带计数器的计时器
然后检查子程序中计数器的状态。但这并没有起作用:
单一的暗淡进展
timer1.enabled = true
进度< 1
textbox1.text =进度
结束时
更多东西
结束分
timer1 tick事件处理程序
进度=进度+.01
结束
文本框告诉我没有发生任何事情。程序挂断了。
这样做的正确方法是什么?这应该是一个线程应用程序吗?
标记
I have a sub which needs to do some things then wait a specified length of
time before going on. I tried adding a timer with counter in its tick event
then checking the state of the counter in the subprocedure. But this doesn''t
work:
dim progress as single
Sub mysub
stuff
timer1.enabled = true
while progress <1
textbox1.text=progress
end while
more stuff
end sub
timer1 tick event handler
progress = progress +.01
end
The textbox shows me that nothing is happening. The program hangs up.
What''s the right way to do this? Should this be a threading application?
--
mark
试试这个标记.. 。
Try this Mark...
Sub mysub
东西
''等一下
System.Threading.Thread.Sleep(1000 )
更多的东西
结束子
" mark"写道:
我有一个sub需要做一些事情然后等待指定的
时间才能继续。我尝试在其勾选事件中添加一个带计数器的计时器
然后检查子程序中计数器的状态。但这并没有起作用:
单一的暗淡进展
timer1.enabled = true
进度< 1
textbox1.text =进度
结束时
更多东西
结束分
timer1 tick事件处理程序
进度=进度+.01
结束
文本框告诉我没有发生任何事情。程序挂断了。
这样做的正确方法是什么?这应该是一个线程应用程序吗?
标记
Sub mysub
stuff
''Wait one second
System.Threading.Thread.Sleep(1000)
more stuff
end sub
"mark" wrote:
I have a sub which needs to do some things then wait a specified length of
time before going on. I tried adding a timer with counter in its tick event
then checking the state of the counter in the subprocedure. But this doesn''t
work:
dim progress as single
Sub mysub
stuff
timer1.enabled = true
while progress <1
textbox1.text=progress
end while
more stuff
end sub
timer1 tick event handler
progress = progress +.01
end
The textbox shows me that nothing is happening. The program hangs up.
What''s the right way to do this? Should this be a threading application?
--
mark
这篇关于具有计时器要求的子程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!