Comments (6)
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.
from winforms.
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.
from winforms.
@KlausLoeffelmann could you take an initial look at this?
from winforms.
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();
}
}
from winforms.
We have checked the background worker with our scenario, but it did not help and caused an exception. When we call DataGrid.Refresh for a specific record by passing in the BackgroundWorker.ReportProgress, it also throws an exception. If we call BackgroundWorker.ReportProgress for a certain limit of records, the value only updates for those records. Please find the sample demo in the attachment. Could you please take a look at that sample and suggest a proper way to achieve this?
from winforms.
@DhivyaBharathi-SF3890 ObservableCollection
is not threadsafe. You can't bind it on the UI thread and then create a separate thread and pass it to it afterwards.
I would avoid using datagrid and instead use a progress bar. Using the background worker report progress to change the progress percentage and some sort of text indicating the number of completed vs total (100/1000). Your dowork event needs to take in parameters, do work (reporting as you go), then return a result. You can't access things on the UI thread in doWork, This is why you pass parameters to it.
from winforms.
Related Issues (20)
- Drawing a line of thickness 1 issue HOT 2
- VisualStudio crashes when calling fileDialog.ShowDialog at DesignTime HOT 6
- Enable `png` based `ico` files and streams to be loaded into `Bitmap` HOT 1
- publish single file doesnt seem to work anymore HOT 9
- NativeHost crash for debug version on .Net 8.0 HOT 7
- RichTextBox will not redraw the last pixel column on resize HOT 11
- IDE0036 errors when building with Preview 6 SDK HOT 5
- PropertyGrid.OnPropertyValueSet: NullReferenceException HOT 1
- Unstable unit test: System.Windows.Forms.Tests.CheckBoxRendererTests.CheckBoxRenderer_DrawCheckBox_OverloadWithSizeAndText
- Unstable unit test: System.Windows.Forms.Tests.TextBoxBaseTests.TextBoxBase_ClearUndo_CanUndo_Success
- Unstable unit test: System.Windows.Forms.Tests.TextBoxBaseTests.TextBoxBase_Copy_PasteNotEmptyWithHandle_Success
- In .NET code is going to exception section when we are trying to convert a sensitivity label doc file to docx format. Exception is Command failed HOT 1
- Controls docked to bottom of SplitContainer within another SplitContainer slowly shift off bottom of panel. HOT 1
- Multiple help links opened, when clicking the Help button in the MessageBox within modal form HOT 8
- Opening Dialog Form on multi-monitor setup using HDPI PerMonitorV2 does not scale properly HOT 3
- Anchoring issue on multi-monitor setup using HDPI PerMonitorV2 HOT 2
- Can .Net8.0-windows Win Form support calling from MFC HOT 5
- ParentControlDesigner/ComponentDesigner is not instantiated/initialized HOT 3
- ShowDialog Intercept Noise HOT 1
- Don't make methods internal for test use, use TestAccessor().Dynamic instead
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from winforms.