更新DataGridView列的HeaderText使GUI无响应

问题描述

我有一个用VB.NET编写的Windows窗体应用程序。 在GUI上的许多其他组件中,还有一个DataGridView。 DataGridView上有9列。 在特定事件下,我更新了DataGridView的每一列的HeaderText。

事件处理程序看起来像这样

Public Sub OnTestStarted(ByRef objNotification As INotifyObject)
 If Me.Invokerequired Then
    Me.BeginInvoke(New onTestStartedDelegate(AddressOf OnTestStarted),New Object() {objNotification})
    Return
 End If
 'Some code goes in here
 DataGridView1.Columns.Item(iCellIndextochange).HeaderText = "Dut" + dutNum.ToString
 'Some code goes in here
End Sub

几乎每隔25ms,就会从4个不同的线程中调用子例程OnTestStarted。 GUI在与调用线程不同的线程上运行。

使用此代码,GUI完全不响应。我看不到GUI的任何组件正在更新。

现在,如果我删除该声明

DataGridView1.Columns.Item(iCellIndextochange).HeaderText = "Dut" + dutNum.ToString

该GUI响应迅速,并且该GUI上的其他组件明显得到刷新。

可能是什么问题和解决方案?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)