0
votes

Subject says it all. I'm actually using the label as a pseudo progress bar, so it has a solid blue background color, no text, and I'm increasing its width on each timer tick. This works great except for one oddball case:

If I leave the window up all day, it's fine.

If I minimize for less than a minute and restore, it's fine.

It's only when I minimize for over a minute (long enough that a tick actually fires), then restore the window, the label doesn't repaint. That is, other labels, which aren't dynamically updated during the tick show up when I restore the window, but the special label that IS dynamically updated is not repainted (the pixels I would expect to be blue are the window's background color, a very light gray). Yes, if the restored window sits there until the next tick, the label repaints blue in the expected way. The window isn't locked up - it responds to input. I'm using a Windows.Forms.Timer dragged onto the form, not a System.Timers.Timer in code.

So, user error or OS/.NET framework bug?

Edit 1: Per answer 1 below, the problem is triggered by attempting to read the width of another label. Why would the window's minimized state affect reading the width of a label?

1
Could you post some code that reproduces the problem?Patrice Gahide
As a quick workaround, you could disable the timer on minimise and restore on maximise. It's a bit rubbish, and would be better to try to fix the reason, but we need more info from you for that...Ian
You say that it works correctly except when a minute passes. The thing is, that your code doesn't work correctly and you are lucky that it works in other occassions. You found an error by luck!γηράσκω δ' αεί πολλά διδασκόμε
I cannot reproduce the problem, so you are going to have to show us the code which is producing the problem. It might help to tell us which OS you are using too.Andrew Morton
When I cloned the project and stripped every seemingly non-essential thing out of it, the stripped version did not exhibit the problem. I will have to do some selective commenting on the full version to see if I can isolate it.amonroejj

1 Answers

0
votes

I've isolated it down to this one line of code, which is in the sub that my tick event calls:

        fakebar.Width = Int((spanSoFar / spanOverall) * (fakeborder.Width - 2))

Inexplicably, omitting the read of the fakeborder object (a label that does NOT get dynamically updated) fixes the problem:

        fakebar.Width = Int((spanSoFar / spanOverall) * (366))

This doesn't seem like user error, but there could be something going on I'm not aware of.