VB.NET-如何从另一个线程读取值 [英] VB.NET - How do you read a value from another thread

查看:44
本文介绍了VB.NET-如何从另一个线程读取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从另一个线程的ui线程上的列表视图中读取一个值.我知道如何使用以下方法设置值:

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)

我收到一个错误,我需要将值分配给某些东西,但不确定在使用invoke时该怎么做.

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

推荐答案

dim selectedItem = CStr(Invoke(New Func(Of String)(Function() Me.lv.Items(x).Text)))

这篇关于VB.NET-如何从另一个线程读取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆