我一直在搞乱这里给出的答案 如何从 C# 中的另一个线程更新 GUI?
我收到错误 Method 'System.Windows.Forms.Label' Text not found from the following code
Private Delegate Sub setControlPropertyThreadSafeDelegate(control As Control, propertyName As String, propertyValue As Object)
Public Sub setControlPropertyThreadSafe(control As Control, propertyName As String, propertyValue As Object)
If control.InvokeRequired = True Then
control.Invoke(New setControlPropertyThreadSafeDelegate(AddressOf setControlPropertyThreadSafe), New Object() {control, propertyName, propertyValue})
Else
control.GetType().InvokeMember(propertyName, Reflection.BindingFlags.SetProperty, Nothing, control, New Object() {control, propertyName, propertyValue}) 'This is where the error occurs
End If
End Sub
从一个单独的线程中,我使用以下行调用此方法
UI.setControlPropertyThreadSafe(UI.lblExcel, "Text", "Inserting Data into YTD Template")
任何有关此错误的帮助将不胜感激。