vb2005设置程序延时执行
━━━━━━━━━━━━━━━━━━━━━━━━━━ 我想实现的是,将程序延时10秒后向下执行。 比如:我在显示器上显示一串字符,显示10秒后在显示下一串字符,显示10秒后再显示下一串。 就是这样连续的显示! 也就是说,程序执行到显示字符串的位置后等待10秒后再向下执行,显示下一串! ━━━━━━━━━━━━━━━━━━━━━━━━━━ 答:PublicSharedSubSleep(ByValmillisecondsTimeoutAsInteger) 成员属于:System.Threading.Thread 摘要: 将当前线程挂起指定的时间。 参数:
millisecondsTimeout:线程被阻止的毫秒数。指定零(0)以指示应挂起此线程以使其他等待线程能够执行。指定System.Threading.Timeout.Infinite以无限期阻止线程。 ━━━━━━━━━━━━━━━━━━━━━━━━━━ 答:1.
Thread.Sleep 這樣做的缺點是,線程被阻塞,等待的過程中不可同時執行其他動作,窗體會假死 2. 使用多線程 3. 使用Timer,本質上也是多線程 答:一是用TIMER定时; 二是用Thread.Sleep(Int32)延时: ━━━━━━━━━━━━━━━━━━━━━━━━━━ 答:延时10秒可能还是time控件好,延时一点点时间用sleep吧
━━━━━━━━━━━━━━━━━━━━━━━━━━ 答:949494
dimwitheventstimerasnewtimer
dimtheTimeasinte subform_load
timer.interval=1000 timer.enabled=true end sub subtimer_tick
thetime=1 if thetime=10 then 'yourcode endif endsub ━━━━━━━━━━━━━━━━━━━━━━━━━━ 答:哦MYCAODE
subtimer_tick thetime=1 ifthetime=10then thetime=0 'yourcode endif endsub ━━━━━━━━━━━━━━━━━━━━━━━━━━ 答:sleep函数.api函数应该不错.
━━━━━━━━━━━━━━━━━━━━━━━━━━ 答:Threading.Thread.Sleep(1000)
Windows.Forms.Application.DoEvents() ━━━━━━━━━━━━━━━━━━━━━━━━━━ 答:是啊,楼上的说的都不错,用Thread.sleep窗体是在这个时间段之内没有响应答:'半秒延迟
System.Threading.Thread.Sleep(500) ━━━━━━━━━━━━━━━━━━━━━━━━━━ 答:谢谢大家
|
|
来自: nxhujiee > 《vb.net技巧》