列表视图问题 [英] list view problem

查看:68
本文介绍了列表视图问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我在项目中使用列表视图来显示一些数据.

listview有超过5000个要显示的元素,但是当我通过调试模式运行程序时,会出现以下错误:
"CLR在60秒钟内无法从COM上下文0x1a1010转换到COM上下文0x1a1180.拥有目标上下文/公寓的线程很可能要么执行非泵浦操作",

当我运行exe时,它运行正常.

谁能给我任何线索,为什么会发生?

Hi all,

I am using a list view in my project to display some data.

The listview has over 5000 elements to display but when I run my program through debug mode then it gives the following error:
"The CLR has been unable to transition from COM context 0x1a1010 to COM context 0x1a1180 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping"

When I run the exe then it is working fine.

Can any body give me any clue why it is happening ?

推荐答案

1.转到调试",异常..."菜单
2.托管调试助手,取消选中ContextSwitchDeadlock

1. goto "Debug", "Exceptions..." menu
2. Managed Debugging Assistants, uncheck ContextSwitchDeadlock

Google[^] it for more details.


您应该在构建它有委托的线程中存储数据.在处理数据时表格不会消失.但我不会在这里讨论.

一个快速的解决方案是在循环中添加Application.doevents的位置添加到列表中.

同样在循环开始之前和循环结束之后,您应该具有以下代码行.

Me.ListBox1.BeginUpdate
Me.ListBox1.endUpdate

只是一些技巧提示.
you should be building this data in a thread with delegates. the form wont die while you process the data. but I wont go into that here.

a quick fix would be to add Application.doevents somewhere in your looping that adds to the list.

also before the loop starts and after the loop finishes, you should have these lines of code.

Me.ListBox1.BeginUpdate
Me.ListBox1.endUpdate

just some tips of stuff to look into.


这篇关于列表视图问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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