public void gifplay(string path,ref Panel panel) { try{ Bitmap animatedGif = new Bitmap(path ); Graphics g = panel.CreateGraphics(); int PropertyTagFrameDelay = 0x5100; PropertyItem propItem = animatedGif.GetPropertyItem(PropertyTagFrameDelay); byte[] bytes = propItem.Value; FrameDimension frameDimension = new FrameDimension(animatedGif.FrameDimensionsList[0]); int frameCount = animatedGif.GetFrameCount(FrameDimension.Time); int[] delays = new int[frameCount + 1]; int i = 0; for (i = 0; i <= frameCount - 1; i++) {delays[i] = BitConverter.ToInt32(bytes, i * 4);} while (true) {for (i = 0; i <= animatedGif.GetFrameCount(frameDimension) - 1; i++){ animatedGif.SelectActiveFrame(frameDimension, i); g.DrawImage(animatedGif, new Point(0, 0)); Application.DoEvents(); Thread.Sleep(delays[i] * 10);} }} catch {return;} }