ietprofessional
Programmer
I'm messing around with OOP concepts and I've found something I really don't understand about the Timer.
Can someone tell me why when I try to run the stopMove method the program freezes?
Thanks,
Harold
class MoveImageWithStop : MoveImage
{
public MoveImageWithStop()
{
this.BoolMove = true;
}
private bool boolMove;
public bool BoolMove
{
get
{
return boolMove;
}
set
{
boolMove = value;
}
}
public void MoveRight(PictureBox picture, int sleep)
{
System.Timers.Timer time = new System.Timers.Timer(300);
while (this.BoolMove == true)
{
base.MoveRight(picture);
time.Start();
}
time.Stop();
}
public void MoveLeft(PictureBox picture, int sleep)
{
System.Timers.Timer time = new System.Timers.Timer(300);
while (this.BoolMove == true)
{
base.MoveLeft(picture);
time.Start();
}
time.Stop();
}
public void stopMove()
{
this.BoolMove = false;
}
}
Can someone tell me why when I try to run the stopMove method the program freezes?
Thanks,
Harold
class MoveImageWithStop : MoveImage
{
public MoveImageWithStop()
{
this.BoolMove = true;
}
private bool boolMove;
public bool BoolMove
{
get
{
return boolMove;
}
set
{
boolMove = value;
}
}
public void MoveRight(PictureBox picture, int sleep)
{
System.Timers.Timer time = new System.Timers.Timer(300);
while (this.BoolMove == true)
{
base.MoveRight(picture);
time.Start();
}
time.Stop();
}
public void MoveLeft(PictureBox picture, int sleep)
{
System.Timers.Timer time = new System.Timers.Timer(300);
while (this.BoolMove == true)
{
base.MoveLeft(picture);
time.Start();
}
time.Stop();
}
public void stopMove()
{
this.BoolMove = false;
}
}