我正在asp.net中运行一个进程,我希望用户在进程运行时以及进程结束时知道。这是我的代码
Private Sub test()
For i As Integer = 0 To 1000 Step 1
Thread.Sleep(100)
Next
Label1.Text = "Process Done"
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
Label1.Text = "Progress Started"
Dim MyTS As New ThreadStart(AddressOf test)
Dim MyThead As New Thread(MyTS)
MyThead.Start()
End Sub
我在此过程中放了一个thead.sleep,因为代码非常广泛并且会导致相当大的延迟,但是当我运行代码并且标签显示“Process Started”时,它从不指示“process Done”。
答案 0 :(得分:0)
您需要检查 Me.Label1.InvokeRequired 是否需要调用,如果需要,请调用函数来设置文本。