OpenNetCF MultiForm UI Framework causing performance issue?

  • Thread starter Thread starter Hollywood
  • Start date Start date
H

Hollywood

I noticed, even running the simple FormStack project (Chris Tacke's original
C# one), that the UI Framework seems to have a performance issue and causes
high load on the CPU. I surmize that this may be caused by the Run method
that repeatedly loops to call DoEvents, i.e.

do {
System.Windows.Forms.Applications.DoEvents();
} while(List.Count > 0)

where List is a list of System.Windows.Forms.Form objects.

Is there a better way to do this? Or perhaps a way to force it to sleep for
a couple milliseconds before checking for events again?

An easy way to show this is to take the FormStack project, add a MainMenu
with a File->Open menu items to the MovieList. Compile in Release mode,
upload to device [I'm using an Axim X5 with PPC2002, SP1] and run it. Click
on the File->Open and the CPU utilization jumps from around ~5% to about 95%
and just stays there.

Thanks for any thoughts, tips, etc...
 
In response, I am now using a root form that is called by using
Application.Run(form) after pushing it onto the MultiUI Framework and
removing any calls to the MultiUI Framework's Run method. Then using the
framework as it was intended. This gives me much better performance!

My question would be, what am I losing [or missing] by doing this and not
constantly calling DoEvents() in a loop?

Thanks again.
 
It's a good question, and it's something I didn't look at (and should have).
The best bet is to write two apps, one that uses Application.Run and one
with the loop. Then look at the IL for the loop and see what they're
implementing. I made an assumption that DoEvents would properly get and
dispatch messages. It's looking like that may not be the case and a "new"
DoEvents is in order. It's only about 5 LOC, so it should be easy to test.

-Chris
 
Back
Top