使用返回线程数据填充列表框 [英] Populating a List box with return thread data

查看:66
本文介绍了使用返回线程数据填充列表框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

全部交易,

我正在开发一个WPF应用程序,它根据本地sql数据库中的类别收集产品数据。基于客户的产品数量可能非常大,我需要提供响应式应用程序。

I am working on a WPF application which collect Product data based on categories from a local sql database. Number of product can be very big based on customer and I need to provide a responsive application.

为此,我要做的第一件事是填充仅包含产品类别的列表框,然后当用户从点亮的框中选择一个类别时,我需要将该列表框的绑定更改为Product集合。

For that the first thing I am doing is populating a List box with only the product categories, then when a user select a category from that lit box, I need to change the binding of that list box to a Product collection.

但我希望能够收集产品数据。每个要收集的产品的线程,并立即通过其列表框中的主题显示产品项目返回。

But I would like is being able to collect Product data in a thread per product to collect and immediately display the Product item return by its thread in list box.

Idealy我希望能够在列表框中显示空项目时的线程开始。空项目将显示一种等待光标,当每个产品线程完成时,我显示产品信息。因此,列表框可​​能会出现在
的开头,其中包含等待光标列表并逐步发现产品数据。然后用户知道每个项目背后发生的事情。

Idealy I would like to be able to display an empty Item in the list box when thread start. The empty Item will display a kind of waiting cursor and when per product thread complete then I display product information. So the list box might appear at beginning with a list of waiting cursor and step by step discover product data. User then knows something happen behind for each item.

然后我会有一个运行的线程池,每个线程都收集产品信息

I will have then a pool of thread running and each of them collecting a product infomation

什么这将是最好的方法吗?

What will be the best way to do that ?

我正在使用.net framwork 4.5

I am using .net framwork 4.5

感谢您的帮助

推荐答案

您好@wakefun,您必须阅读这些文章才能实现目标。

Hi @wakefun, you must read these articles in order to achieve your goals.


  • < a href ="http://msdn.microsoft.com/en-us/library/vstudio/9k7k7cf0(v=vs.120).aspx\"target ="_ blank">收益率(C#参考)
  • < a href ="http://msdn.microsoft.com/en-us/library/hh524395.aspx?cs-save-lang=1&cs-lang=csharp"target ="_ blank">异步返回类型
  • 统一
    async,await和yield return

希望有所帮助。


这篇关于使用返回线程数据填充列表框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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