c#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); } } }