在VB.NET中使用sleep(5000)之前如何获取语句的输出?是什么函数等同于Sleep()? [英] How do I get output for the statement before using sleep(5000) in VB.NET? Is thr any function equivalent to Sleep() ?

查看:94
本文介绍了在VB.NET中使用sleep(5000)之前如何获取语句的输出?是什么函数等同于Sleep()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        While NextFrame <= numericUpDown1.Value
            Controls("Label" & NextFrame.ToString()).BackColor = Color.Yellow
            Sleep(2000)
            handler.Send(Encoding.ASCII.GetBytes(NextFrame.ToString()))
            NextFrame = NextFrame + 1
        End While
    End Sub





color.yellow在睡觉前工作(2000)但我们可以' t可视化黄色。将黄色作为输出的解决方案是什么?



color.yellow is working before sleep(2000) but we can't visualize that yellow color. What is the solution to get yellow color as output?

推荐答案

在进入sleep()之前尝试向控件添加Refresh()方法。

问题是在睡眠期间整个线程都被冻结,即使是消息循环和控件调度也不起作用。

也许你会使用不同的方法来等待(即使用计时器)。

您可能需要查看这个讨论主题。
Try adding a Refresh() method to your control before entering the sleep().
The problem is that during sleep the whole thread is frozen even the message loop and controls dispatching don't works.
Maybe you wan use a different method to wait (i.e. using a timer).
You may want have a look to this discussion thread.


这篇关于在VB.NET中使用sleep(5000)之前如何获取语句的输出?是什么函数等同于Sleep()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆