2

I have a winforms app, and pops up some windows from time to time depending on what the user clicks on. Lately, users have been complaining that the pop ups take too long to appear. If I profile the code, or put in a Stopwatch, I see that my C# code finishes process the Show() method in about 50ms, but the window itself won't appear for almost a second.

Is there any way to measure that amount time until the window actually appears?

2 Answers 2

3

I think the Shown event fires after the drawing is completed.

See Form.Shown Event and Order of Events in Windows Forms

Sign up to request clarification or add additional context in comments.

1 Comment

Actually this will not measure how long it takes for your form to appear. Or at least, when I checked this out, the Shown event fired after 50ms, but the form wasn't visible for a couple hundred milliseconds.
2

Measuring the time until the first OnPaint call could be a way. It is called as a response to the WM_PAINT message, which is sent by Windows to a Window when it should be redrawn. If you take a measurement both before and after the base.OnPaint() call you can also see how long the actual drawing code takes to complete.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.