Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VB.NET - How do you read a value from another thread

Tags:

.net

vb.net

I need to read a value from a listview that is on the ui thread from another thread. I know how to set a value using:

Invoke(Sub() Me.lv.Items.add("data"))

But I need to retrieve a value from a listview and am not sure how. Here is what I have so far:

dim selectedItem = Invoke(Sub() Me.lv.Items(x).Text)

I get an error that I need to assign the value to something, but not sure how to do that when I use invoke.

like image 835
rerat Avatar asked Feb 23 '26 09:02

rerat


1 Answers

dim selectedItem = CStr(Invoke(New Func(Of String)(Function() Me.lv.Items(x).Text)))
like image 195
Thomas Levesque Avatar answered Feb 24 '26 22:02

Thomas Levesque



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!