开发者

Slow down Console speed

开发者 https://www.devze.com 2023-03-26 18:49 出处:网络
I have this prog开发者_开发问答ram, which prints a sine wave but it\'s too fast, how can I slow down the console\'s line printing speed?

I have this prog开发者_开发问答ram, which prints a sine wave but it's too fast, how can I slow down the console's line printing speed?

    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


You can write Thread.Sleep(TimeSpan.FromHours(1)).
(Although you may want FromSeconds instead)


I usually prefer: System.Threading.Thread.Sleep(miliseconds), easier syntax in my own opinion of course. ;-)

0

精彩评论

暂无评论...
验证码 换一张
取 消