1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

.NET framework poor performance

Discussion in 'HTML, Graphics & Programming' started by SoapSurgeon, 2 Mar 2006.

  1. SoapSurgeon

    Wise Guy

    Joined: 14 Apr 2003

    Posts: 1,101

    Hi,

    Ive been developing an application with c#.net and was really happy with it until i noticed how annoyingly long it takes to redraw everything. I changed from using system colours to my own gui (which is nothing more than a solid background with a border) and now when you move a form around you can see it lagging.

    Part of my program uses a 2000x2000 image which is drawn in a picturebox contained within a panel (for the use of its auto scroll) and when dragging a form across that its just awful!! I noticed that whilst redrawing the program uses up 99% of the processor sometimes, which may account for the poor performance...

    Anyway not so much a question as a rant about the shoddy performance of .NET, my program isnt as complex as some comercial programs and they redraw themselves ok.

    Maybe im doing something wrong so any advice would be helpful, otherwise what are your opinions on the .net framework (i used to love it)

    Matt
     
  2. NathanE

    Capodecina

    Joined: 21 Oct 2002

    Posts: 18,022

    Location: London & Singapore

    The problem is the 2000x2000 image ;) Handling images of that size means you can't really rely on the standard image control included with .NET. They just aren't designed to handle that sort of resolution. A good place to start experimenting is subclassing it and overriding some of its paint/scroll events to give yourself a finer grained control.

    Although .NET GUI app's are much much faster than their Java Swing counterparts, there is still plenty of room for improvement on Microsoft's part. That improvement is coming in Vista with the arrival of WinFX. The current Windows Forms system is constantly performing Win32 Interop to access all the common controls. Interop is a costly process. WinFX provides a totally managed GUI library and do the overhead of Interop is removed entirely.
     
  3. topbanana

    Hitman

    Joined: 15 Jun 2005

    Posts: 631

    Yes I also don't think you can blame the framework as WinForms is only one part of it, and it can't be all things to all men. You might like to try rescaling the image to the size of your control before loading it in.
     
  4. SoapSurgeon

    Wise Guy

    Joined: 14 Apr 2003

    Posts: 1,101

    yeah i suppose the .net framework isnt that bad, i just dont like winforms. Unfortunately i cant rescale the image anymore because it is a map of an area of england and i have already scaled it down by a factor of 4 (it was 8000x8000) which is just about readable but any lower and its pointless. I was thinking of loading in part of it and when you scroll it loads the next part from memory, would that be any good?
     
  5. NathanE

    Capodecina

    Joined: 21 Oct 2002

    Posts: 18,022

    Location: London & Singapore

    Yes that sounds good. You basically need to write code for a more efficient image box. One that is suited to very large scrollable images.

    You'll probably need to use unsafe code such as pointers to get substantial performance gains.
     
  6. Lagz

    Wise Guy

    Joined: 25 Jul 2003

    Posts: 1,980

    Or something like openGL?