how can i delay compiler??

In order to see the changes I want to add delay time. That is actually the "timeFly()" method's work. But this is not suitable and reduces the performance. Can I use Timer class for this aim If yes, How can i write code statement

private void timeFly()

{

for (int i = 0; i < 12000000; i++)

{ }

}

private void fly()

{

int t = 0;

timeFly();

timeFly();

while (t < 50)

{

this.pictureBox36.Image = Properties.Resources.fly1;

timeFly();

this.pictureBox36.Image = Properties.Resources.fly2;

timeFly();

this.pictureBox36.Image = Properties.Resources.fly3;

++t;

this.pictureBox36.Location = new Point(a, b);

a -= 5;

b -= 2;

}



Answer this question

how can i delay compiler??

  • Bhasker

    It is ok. Thank you very much for your respond :)


  • Steven J. Reed

    you could put the thread to sleep for a few seconds, which would make the entire main thread sleep for that amount of milliseconds:

    System.Threading.Thread.Sleep(2000); //2 second sleep

     

    I guess another way is to as you suggested put a timer on, set the interval, on each tick event, then call the method/do stuff or something.



  • how can i delay compiler??