Results 1 to 2 of 2

Thread: Accessing DataGridView from parallel thread

  1. #1

    Thread Starter
    Member RaZeR's Avatar
    Join Date
    Jan 2009
    Location
    Russia, Moscow
    Posts
    38

    Unhappy Accessing DataGridView from parallel thread

    Hello
    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?

    RaZeR.
    VB 6, VB.NET, C#, Java, JavaME, C/C++ and Assembler Programmer


    If my post was helpful, rate me

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width