c# 异步更新UI,如何得知结束
现在的功能是,开辟一个新线程用来拷贝文件,要实时的更新UI上的进度条和Label
代码
Dim t As Thread = New Thread(New ParameterizedThreadStart(AddressOf CopyFiles)) t.IsBackground = True t.Start(fileList) Private Sub CopyFiles(ByVal myList As List(Of String)) 拷贝文件代码 '线程切换更新UI线程UI的值 Me.BeginInvoke(New MyDelegate(AddressOf UpdateInfo), fileNowInt, srcfileName) Thread.Sleep(2000) End If Catch Continue For End Try Next End Sub Private Sub UpdateInfo(ByVal cnt As Integer, ByVal fileName As String) pbUpdate.Value = cnt lblUpdateFile.Text = fileName lblUpdateFileCount.Text = String.Format("{1}/{0}", updateFileList.Count, cnt) End Sub