Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unresponsiveness issue during Real-Time Updates in Winforms DataGridView #11335

Open
DhivyaBharathi-SF3890 opened this issue May 8, 2024 · 4 comments
Assignees
Labels
area-Controls-DataGridView 📭 waiting-author-feedback The team requires more information from the author tenet-performance Improve performance, flag performance regressions across core releases
Milestone

Comments

@DhivyaBharathi-SF3890
Copy link

.NET version

.Net 7.0

Did it work in .NET Framework?

No

Did it work in any of the earlier releases of .NET Core or .NET 5+?

No response

Issue description

In DataGridView, while updating the values like real-time updates, the demo becomes unresponsive. Without using the Refresh() method the values are not updated.

DataGrid_Refresh.zip

Steps to reproduce

1.Run the sample.
2.Click the Refresh button.

Observed Behavior:
The sample enters into the Not responding state

@DhivyaBharathi-SF3890 DhivyaBharathi-SF3890 added the untriaged The team needs to look at this issue in the next triage label May 8, 2024
@lonitra
Copy link
Member

lonitra commented May 8, 2024

@KlausLoeffelmann could you take an initial look at this?

@elachlan elachlan added tenet-performance Improve performance, flag performance regressions across core releases area-Controls-DataGridView labels May 9, 2024
@Zheng-Li01
Copy link
Member

Zheng-Li01 commented May 9, 2024

The issue can reproduce both .NET from 6.0 to 9.0 and .NET Framework 4.7.2 to 4.8.1 as below screenshot.
11335

@LeafShi1
Copy link
Member

This issue can be reproduced using the following simple code

 private void button1_Click(object sender, EventArgs e)
 {
     for (int i = 0; i < 100000; i++)
     {
         dataGridView1.Refresh();
     }
 }

WinFormsApp7.zip

@merriemcgaw merriemcgaw removed the untriaged The team needs to look at this issue in the next triage label May 15, 2024
@merriemcgaw merriemcgaw added this to the Future milestone May 15, 2024
@elachlan
Copy link
Contributor

I don't think this is a bug. You are using thread.sleep in the UI thread. DataGridView.Refresh will trigger an invalidation of the whole gridview and repaint it. All of that will end up locking the UI thread.

It would be better to use a separate thread (via a background worker or similar) to report progress to the UI thread. BackgroundWorker.ReportProgress allows you to pass an object as well. Which can be your "progress" class.

@elachlan elachlan added the 📭 waiting-author-feedback The team requires more information from the author label May 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Controls-DataGridView 📭 waiting-author-feedback The team requires more information from the author tenet-performance Improve performance, flag performance regressions across core releases
Projects
None yet
Development

No branches or pull requests

7 participants