0
我有2個像下面這樣的子,當我用1000次迭代和capturePicture()在其中進行循環時。經過700次迭代後,事件不再發生。 任何人都可以幫助我嗎?事件在一個循環中停止觸發
Public Sub capturePicture()
Try
AddHandler capturePic.FrameEvent2, AddressOf CaptureDone
capturePic.GrapImg()
Threading.Thread.Sleep(270)
Catch ex As Exception
RemoveHandler capturePic.FrameEvent2, AddressOf CaptureDone
End Try
End Sub
Private Sub CaptureDone(ByVal e As Bitmap)
Try
Me.PictureBox1.Image = e
PictureBox1.Image.Save(MakeFileNameWithAutoIncrement(MakeFolderNameForCurrentDate(MyFolderName) + "\" + MyTimeStampDatumVrijeme() + "_" + Filename4Cam + "-CAM1(" + CamEvent + ").JPG"), System.Drawing.Imaging.ImageFormat.Jpeg)
RemoveHandler capturePic.FrameEvent2, AddressOf CaptureDone
Catch ex As Exception
RemoveHandler capturePic.FrameEvent2, AddressOf CaptureDone
End Try
End Sub
Thread.Sleep調用的目的是什麼? –
如果我們刪除thread.sleep,我們只拍攝一張照片。 thread.sleep使我們能夠正常運行循環。 – user109285