I have an app originally written in VB6 that draws the Mandelbrot set. I loop through each pixel in a picture control, calculate the proper color for that pixel, and set the color, doing a refresh after each line. When I converted this to .NET it drew considerably slower. If I happen to minimize the app so that it doesn't have to draw anything the speed is fine.

Here are the times I'm getting for a particular view:
VB6 3 seconds
.NET (foreground) 14 seconds
.NET (background) 2 seconds

Here's a simplified piece of the VB6 code:

VB Code:
  1. mypicture.autoredraw = true   ' set at design time
  2. for x = 1 to 600
  3.   for y = 1 to 400
  4.     iterations=calculatepoint(x,y)  ' this function is where all the heavy math happens
  5.     mypicture.pset (x,y), colorlist(iterations)  ' there's more logic going on here, but this is the important part
  6.   next y
  7.   doevents
  8. next x

And here's the VB.NET code

VB Code:
  1. bmap = new bitmap(600,400,system.drawing.imaging.pixelformat.format24bpprgb)
  2. mypicture.image = bmap  ' these two lines done in form.load
  3. for x = 1 to 600
  4.   for y = 1 to 400
  5.     iterations=calculatepoint(x,y)  ' this function is where all the heavy math happens
  6.     bmap.setpixel(x,y,colorlist(iterations))  ' again, this is the important part
  7.   next y
  8.   mypicture.refresh()
  9.   system.windows.forms.application.doevents()
  10. next x

Is this the correct approach to this manner of drawing? Is there something I may be missing?

Thanks,
Dennis