FlexGrid for WinForms

Performance question: CellStyle.BackColor and .ForeColor

  •  Wolfgang Knauf7p said 1 year, 1 month ago:

    Hi C1,

    hope that someone can help me. We have some quite complex flexgrids with a lot of styles, so we invented a helper class which encapsulates "on the fly creation of necessary styles". When breaking in debugger while we fill our grid, it often is stuck at "CellStyle.BackColor.get" or "CellStyle.ForeColor.get".
    See attached screenshot with debugger stacktrace and "local variables" window.

    According to the debugger stacktrace, a Graphics object is created, and this seems to be a costly operation. Is the creation of this Graphics object during "get" of the BackColor really necessary?

    Best regards

    Wolfgang

    Attachments:
    You must be logged in to view attched files.
  •  Reeva1p said 1 year ago:

    Hello,

    We have escalated your issue to the concerned team. We will get back to you soon on the same.

    Thanks,
    Reeva Dhingra

  •  Reeva1p said 1 year ago:

    Hello,

    Our developers aren’t able to replicate the issue and they ain’t able to see any graphics object being created when getting/setting BackColor and ForeColor.

    Could you please provide us with the portion of the code that produces this stack trace?

    Thanks,
    Reeva Dhingra

  •  Wolfgang Knauf7p said 1 year ago:

    Hi Reeva,

    sorry for the delay. The issue of my original question is hard to reproduce. In our "real world" app, code execution is often located at "Graphics.FromHwnd", when I just click the "break into debugger" button during a longer operation.
    But I managed to create a small sample, based on my "Stylehandler" helperclass from here: http://our.componentone.com/groups/winforms/flexgrid-for-winforms/forum/topic/5205

    To reproduce, best set a break point in the "button1_Click" handler, e.g. at line 154. Then click the button – debugger should stop at the breakpoint.

    NOW, it is time to create a breakpoint at "Graphics.FromHwnd": in the "Breakpoints" view, click the button "Import breakpoints from a file" and pick the file "stylehandlerbreakpoints.xml" in the attached samples. If all works as expected, there should be a breakpoint in "Graphics.FromHwnd".
    When you continue debugging, you will find that this breakpoint is hit for every cell.

    So it seems that a Graphics object is created each time the ForeColor or BackColor of a cell style is queried.

    Note that the re-import of the breakpoints file seems to be necessary for each debugging run.

    Best regards

    Wolfgang

    Attachments:
    You must be logged in to view attched files.
  •  C1_BernardoC7p said 12 months ago:

    Hello Wolfgang. It’s been a long time!

    I looked into this issue and found that the CellStyle constructor does call Graphics.FromHwnd.

    The good news is I am pretty sure it only needs to do that in rare situations, so we should be able to skip that step in most cases.

    The latest maintenance version of the grid, 686, has this optimization. It should be available for download shortly.

    Thanks for bringing this up.

    Answer
  •  Wolfgang Knauf7p said 12 months ago:

    Sounds promising, many thanks!

    It will probably just be a minor improvement, but better than nothing ;-) .

    Best regards

    Wolfgang

  •  Wolfgang Knauf7p said 11 months ago:

    I see that the change is in .698. I applied the new version and hope that it slightly improves performance ;-)

    Best regards

    Wolfgang

  •  C1_BernardoC7p said 11 months ago:

    Looking forward to your feedback Wolfgang.Thanks in advance.

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.