1

To stop my application from flickering, I tried to activate DoubleBuffering for all of my controls and subcontrols.

To achieve this, I added the follwoing codesnippet in my mainform:

protected override CreateParams CreateParams
    {
        get
        {
            CreateParams cp = base.CreateParams;
            cp.ExStyle |= 0x02000000; //WS_EX_COMPOS

            return cp;
        }
    }

The problem is, that with WindowsXP the cpu-load becomes almost 100% and keeps up. No problem on Windows7.

It looks for me, as it is the very same problem as in this question. Is there a "easy" solution in C#? Or asked in a different way -> What usually causes this behaviour? So I can find out the problem in my application.

UPDATE: Maybe some more information to help you folks help me. What I am trying to do is showing a semi-transparent form ontop of the mainform with an progressbar. This "progressBarForm" is in a second thread to have this progressbar running. On Win7 everything works fine, as mentioned above with WinXP (.net4, activated desktoptheme) there is 100% cpu-load after the progressbar was shown once - also the acutal payload-function needs much longer to complete - maybe because of the high-cpu-load done by the progressbar. Where and what should I check again? Some ideas?

Btw.: I don't think the thread is a problem, as when I show the form in the mainthread and don't refresh anything, the result (high cpu-load) is the same...

Community
  • 1
  • 1
basti
  • 2,649
  • 3
  • 31
  • 46
  • 100% cpu load is normally a *good* thing, it means that your program is running at maximum possible speed, not bogged down by I/O. Unless it constantly runs at that load, then you are asking the machine to do more than it can do. Or you have a bug in your code, like invalidating the window in the Paint event handler. – Hans Passant Jun 05 '12 at 11:04
  • I am not running any Paint-Event-handler in this case. And it runs at 100% and stays there. There is nothing more to do. – basti Jun 05 '12 at 11:24
  • Well, as long as you throw up your hands in despair and can't post better repro code then checking Environment.OSVersion in your CreateParams overload would be a wise thing to do. – Hans Passant Jun 05 '12 at 11:28
  • With nothing more to do, I meant that the application is in idle-state, but the cpu-load doesn't decrease. Not that I am not willing to try out more things :) What code do you need more? What could help you, repro my problem? – basti Jun 05 '12 at 11:31

0 Answers0