none
Clearing datagridview very slow on first time.

    Question

  • I've written a program that integrates with some 3d modelling software. It takes a model and finds all the sub components within the high level assembly and lists them in a datagridview.

    Because this process can take a while, I wanted to put this in a backgroundworker and enable the user to cancel if they want. This all works fine except that whenever the datagridview is populated (unbound) and the sub finishes, it spends the next 30 seconds thinking about "something". Any interaction in this time frame isn't registered. This only occurs when the datagridview requires a scrollbar. If the list of items is short, there is no issue.

    I only have this problem when I populate the datagridview from the background worker. If I run it in the top thread I have no issues.

    It should be noted that I'm completely self-taught in regards to programming.


    • Edited by Timfurtimfur Tuesday, April 24, 2018 3:17 PM Added more accurate details
    Tuesday, April 24, 2018 2:30 PM

Answers

  • I found the answer, sorry for the distraction.

    There is a bug it seems in windows when dealing with backgroundworkers and datagridviews

    My account is unverified so i'm not able to include links to examples.

    The way I was able to work around it was rather than build the data in the datagridview at runtime, I built the data into a datatable, and then populated the datagridview from the table after the operation had completed. This stops the repetitious painting calls that seem to cause the error.

    • Marked as answer by Timfurtimfur Tuesday, April 24, 2018 4:21 PM
    Tuesday, April 24, 2018 4:21 PM

All replies

  • I found the answer, sorry for the distraction.

    There is a bug it seems in windows when dealing with backgroundworkers and datagridviews

    My account is unverified so i'm not able to include links to examples.

    The way I was able to work around it was rather than build the data in the datagridview at runtime, I built the data into a datatable, and then populated the datagridview from the table after the operation had completed. This stops the repetitious painting calls that seem to cause the error.

    • Marked as answer by Timfurtimfur Tuesday, April 24, 2018 4:21 PM
    Tuesday, April 24, 2018 4:21 PM
  • Really thanks for sharing your solution here. Timfurtimfur.

    Any debug issue, feel free to post it here.

    Have a nice day,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, April 26, 2018 9:16 AM
    Moderator