0

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:

  1. How to speed up using InvokeRequired?
  2. How to refresh dataGridView1 after filling dataGridView1.Rows.Add from serialPort1_DataReceived?

enter image description here

uriy
  • 1
  • *Received data is stored in datagridview* - I wouldn't; I'd store it in something else dedicated and show it in the DGV on an occasional/filtered basis – Caius Jard May 31 '22 at 07:24
  • Hm. Maybe. For example store in global struct and fill DGV from timer event couple times per second? – uriy May 31 '22 at 07:39
  • Hmm.. Run wireshark or procmon, or some other tool that blasts huge numbers of updates onto screen every second - what's the first thing you do to make the data usable? – Caius Jard May 31 '22 at 07:54
  • Yes, I'm doing wireshark design. In bottom I'm already showing hex value like wireshark. But for middle panel I didn't find yet solution how to do it in C# like wireshark design. – uriy May 31 '22 at 08:01
  • It's not my point. My point is blasting 100 events a second onto the screen is just completely unmanageable for a human to take in, so there isn't much point trying to speed it up; load your data into a backing store, and have the grid show filtered, relevant items, which would usefully be far lower than the eventing rate. At some point you might have to look at double buffering the DGV, btw – Caius Jard May 31 '22 at 08:05
  • Please provide enough code so others can better understand or reproduce the problem. – Community May 31 '22 at 11:55

0 Answers0