private bool isAnimating = false;
private void Button1_Click( object sender, System.EventArgs e) 
{
    // Stop animation
    System.Drawing.ImageAnimator.StopAnimate( 
        this.PictureBox1.Image, this.OnFrameChanged);
}
private void Button2_Click( object sender, System.EventArgs e) 
{
   System.Drawing.ImageAnimator.Animate( 
        this.PictureBox1.Image, this.OnFrameChanged);
    isAnimating = false;
}
private void OnFrameChanged( object sender, EventArgs e)
{
    // Force  call to the Paint event handler
    this.Invalidate();
}
private void AnimateImage()
{
    if( !isAnimating )
   {
        // Begin animation only once.
        System.Drawing.ImageAnimator.Animate(this.PictureBox1.Image, 
            this.OnFrameChanged);
        isAnimating = true;
    }
}
protected override void OnPaint(PaintEventArgs e)
{
    // Begin the animation.
    AnimateImage();
    // Get the next frame ready for rendering.
    ImageAnimator.UpdateFrames();
    // Draw the next frame in the animation.
    e.Graphics.DrawImage(this.PictureBox1.Image, 
      this.PictureBox1.Location.X, this.PictureBox1.Location.Y);
}
                 |