减慢控制台速度

时间:2011-08-07 22:28:06

标签: .net vb.net

我有这个程序,它打印正弦波,但速度太快,我怎么能减慢控制台的行打印速度呢?

    Sub Main()
        Dim x As Double = 0
        Do
            Console.Write(times(" ", Math.Sin(x) * 10 + 30))
            Console.WriteLine("@")
            x += 0.1
        Loop
    End Sub

    Private Function times(ByVal ch As Char, ByVal t As Integer) As String
        Dim result As String = ""
        For i = 0 To t
            result += ch
        Next

        Return result
    End Function

2 个答案:

答案 0 :(得分:4)

你可以写Thread.Sleep(TimeSpan.FromHours(1)) (尽管您可能需要FromSeconds

答案 1 :(得分:3)

我通常更喜欢:System.Threading.Thread.Sleep(miliseconds),当然我自己认为语法更简单。 ; - )