Suppose I need to draw pixel by pixel with some delay so that the points are displayed one by one. I wrote the following code:
for (int i = 0; i < 300; ++i)
{
Random random = new Random();
Point point = new Point(random.Next(0, bmp.Width), random.Next(0, bmp.Height));
bmp.SetPixel(point.X, point.Y, Color.Black);
pictureBox1.Image = bmp;
Thread.Sleep(10);
}
But it doesn't work! The program freezes until 300 points are set on the bitmap, and then displays them all at the same time on the pictureBox
What am I doing wrong ? I didn't find anything about that.
I would be grateful for any advice, why this is happening and how to fix it. Sorry for my bad english.