我想從委託函數中獲取值。基本上我試圖從委託函數獲取richboxtext行長度。代表函數返回值
這裏是我的功能
Private Delegate Function getrichlengthmain(ByVal TB As RichTextBox) As String
Private Function getrichlenghtdele(ByVal TB As RichTextBox) As string
Return TB.Lines.Length
End Function
而且我通過
Dim d As getrichlengthmain
d = AddressOf getrichlenghtdele
dim returnvalue as string
returnvalue = d.BeginInvoke(FstList,nothing,nothing)
兩個問題在此代碼
1日問題
調用它,當我的代碼更改「 returnvalue = d.BeginInvoke(FstList,nothing,nothing)「to」d.BeginInvoke(FstList,nothing,nothing)「
的跨線程錯誤彈出式視窗,同時debuiging
第二個問題
我如何從函數的值沒有得到任何橫紗錯誤。
非常感謝您的時間和提前感謝解決它。
'BeginInvoke'用於異步調用委託。那是你想要做的嗎?如果是這樣,你可能不希望在功能可能仍在運行時得到結果。如果不是,你爲什麼使用'BeginInvoke'? – hvd
感謝您的回覆。我正在使用begininvoke,因爲我想讓函數安全地從richtextbox獲取行長度。有沒有其他方法可以通過使用函數來從richtextbox安全地獲取行長度。 –