views:

53

answers:

3

Hi!

Im doing a Naval Battle for University. I decided to do it in C#. My board is 20 x 20 of mini (20x20) PictureBoxes. The problem is when I load the board I got a huuuge delay for draw all of them in the panel which contains them. So I thought to ThreadPool my method to escale the picuteres boxes creation and drawing fester.

Is this the correct aproach? I'm wondering if even if I launch 20 threads to create and set the picturesoboxes together I will still have the graphic delay.

(I wont past code right now because maybe the answer independs of it... if not, I past next :)

Sorry the bad english,

Thanks folks!

A: 

Basically this would not be very ok because you should not change the UI from other threads beside the main one. Doing that would result in improper behaviour. You could check the code where you load the pictures, probably it can be improved or just think of a different implementation.

Adrian Faciu
A: 

Take a look at 2 sample projects from codeproject:

volody
A: 
  1. Use a single thread.
  2. Definatly suspend UI updates while building the UI, then resume updates.

Perhaps construct a single bitmap in memory (you can draw the small ones onto the graphics object the bitmap represents) then display the single bitmap. (with this method look at double buffering also)

MaLio