R
Ringo
I'm drawing in a picturebox. Right now for testing I have a loop that
does
for (int x = 0; x < 10; x++)
{
DrawSonar();
RobotX += 10;
PB.Invalidate();
Thread.Sleep(200);
}
and
private void DrawSonar()
{
Graphics objGraphics = Graphics.FromImage
(m_objDrawingSurface);
.....
for (angle = (Angle - (BeamWidth / 2)); angle < (Angle +
(BeamWidth / 2)); angle += 2)
{
endX = RobotX + (int)(Range * Math.Cos(angle * 6.28 /
360));
endY = RobotY + (int)(Range * Math.Sin(angle * 6.28 /
360));
objGraphics.DrawLine(Pens.Green, RobotX, RobotY, endX,
endY);
}
objGraphics.Dispose();
PB.Invalidate();
}
The problem is that the screen does no update until after the loop is
done.
Eventually the loop will be relpaced with a timer, but for testing the
loop is easy. What do I do to make it update after each loop?
Thanks
Ringo
does
for (int x = 0; x < 10; x++)
{
DrawSonar();
RobotX += 10;
PB.Invalidate();
Thread.Sleep(200);
}
and
private void DrawSonar()
{
Graphics objGraphics = Graphics.FromImage
(m_objDrawingSurface);
.....
for (angle = (Angle - (BeamWidth / 2)); angle < (Angle +
(BeamWidth / 2)); angle += 2)
{
endX = RobotX + (int)(Range * Math.Cos(angle * 6.28 /
360));
endY = RobotY + (int)(Range * Math.Sin(angle * 6.28 /
360));
objGraphics.DrawLine(Pens.Green, RobotX, RobotY, endX,
endY);
}
objGraphics.Dispose();
PB.Invalidate();
}
The problem is that the screen does no update until after the loop is
done.
Eventually the loop will be relpaced with a timer, but for testing the
loop is easy. What do I do to make it update after each loop?
Thanks
Ringo