Accessing DataGridView from parallel thread
Hello :wave:
I have one question.
In my program (PassGen) i have a DataGridView control that stores passwords.
But when i add more about 20,000 or more entries at the same time (using "Generate List", UI freezes up for a few minutes.
I tried to add new entries from a background thread (so main thread will redraw the form), but run into exceptions :(
How to do that? :confused:
RaZeR.
Re: Accessing DataGridView from parallel thread
The same goes for any control: you cannot access it form any thread other than the one it was created on. You need to do as much work as you can on the secondary thread but actually adding the values to the grid MUST be done on the UI thread. I would suggest generating your list on the secondary thread and then simply binding that list on the UI thread. Follow the CodeBank link in my signature and check out my posts on Using The BackgroundWorker and Access Controls From Worker Threads for more information. If you need more help then please provide a more complete description of exactly what you're doing, i.e. exactly what data is in the grid and how it gets there.