DataGridView Invokerequired Works工作慢
我正在开发用于记录RS232数据的软件。每个毫秒收到了很多数据。收到的数据存储在DataGridView中,您可以在附件图片上看到。 对于填充数据,我使用datagridview1.invokerequrequred serialport1_datareceived事件。 当RS232上只有几个数据时,它可以正常工作。但是,当它收到RS232 RS232的许多数据包时,GUI的工作缓慢。按下按钮没有反应,应用程序会消耗CPU。一旦我断开RS232实际上没有新数据,按钮立即按下响应。 我的第二种方法是直接从serialport1_datareceived事件中使用datagridview1.rows.add。在这种情况下,它运行迅速,按钮负责。但是DataGridView1不会刷新,有时会闪烁。我已经在使用双重缓冲。
所以我的问题是:
- 如何使用Invokerequired加速?
- 如何在填充datagridview1.rows.add的serialport1_dataReceived后刷新datagridview1?
I'm developing software for logging data from RS232. There is a lot of data received each millisecond. Received data is stored in datagridview, you can see on attached picture.
For filling data I use dataGridView1.InvokeRequired from serialPort1_DataReceived event.
It works fine when there is just a few data on RS232. But when it receives many packets from RS232 GUI is working slow. There is no reaction for buttons pressing, and application consumes CPU. Once I disconnect RS232 physically there is no new data, buttons pressing response immediately.
My second approach was using dataGridView1.Rows.Add directly from serialPort1_DataReceived event. In this case it works fast, buttons are responsible. But dataGridView1 doesn't refresh, and some times flicker. I'm already using double buffering for it.
So my questions are:
- How to speed up using InvokeRequired?
- How to refresh dataGridView1 after filling dataGridView1.Rows.Add from serialPort1_DataReceived?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论