c# pictureBox 循环播放图片

c#

1.遍历目录 查找图片
2.在 pictureBox 循环播放


public void PlayThread()//CMD_UpdateBtnStatus cmd
        {
            Int32 framerate = 30;
            Int32 interval = 1000 / framerate;

            string suffix = "*.jpg";
            List<String> list = Utility.TraverseDirector(videoFramePath, false, true, suffix);
            if (list.Count == 0)
            {
                return;
            }

            UInt32 count = (UInt32)list.Count;

            while (_ImagePlayThreadLoop)
            {
                for (UInt32 index = 0; index < count; index++)
                {
                    //this.Invoke((EventHandler)(delegate   //数据返回错误
                    //{
                    //Tab4_UVC_pictureBox.Load(list[(Int32)index]); //同步方式 必须要delegate 方式更新(手动添加 异步方式)
                    //不能在这里sleep 会卡死UI线程
                    //}));

                    //直接用异步方式,更新图片数据

                    //文件不存在就continue;
                    if (!File.Exists(list[(Int32)index])) continue;

                    Tab4_UVC_pictureBox.LoadAsync(list[(Int32)index]);

                    if (!_ImagePlayThreadLoop)
                    {
                        index = count;
                        //continue;
                        return;
                    }
                    if (index >= count)
                    {
                        index = 0;
                    }
                    Thread.Sleep(interval);
                }
            }
        }
posted @ 2018-12-14 10:42  scott_h  阅读(3047)  评论(0编辑  收藏  举报