其实还有其它的方法来延迟过程,并不卡死窗体。
' 导入 Threading 命名空间
Imports System.Threading
Public Class Form1
' 创建延迟函数
Public Async Function Delay(ByVal milliseconds As Integer) As Task
Await Task.Delay(milliseconds)
End Function
' 使用示例
Private Async Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
For i = 0 To 10
ListBox1.Items.Add(i)
Await Delay(3000) ' 延迟 3 秒
Next
End Sub
End Class