【发布时间】:2023-03-24 15:18:01
【问题描述】:
我想知道如何制作流程..
我实际上是用这样的 For 来做这个的:
timeCount = 0
Timer.Start()
Dim Count As Integer = 1, next As Boolean
For Each dataRow As DataRow In DataBase.Rows
nextImage = False
Do While nextImage = False
Try
Dim Ext As String = ".png"
If rbJPG.Checked = True Then Ext = ".jpg"
GenerateImage(dataRow, ImageFrom, FBD.SelectedPath, Ext, Count)
nextImage = True
Catch ex As Exception
Timer.Stop()
Dim Result As DialogResult = MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error)
If Result = Windows.Forms.DialogResult.Ignore Then
Timer.Start()
nextImage = True
ElseIf Result = Windows.Forms.DialogResult.Retry Then
Timer.Start()
nextImage = False
ElseIf Result = Windows.Forms.DialogResult.Abort Then
prgGenerate.Value = 0
Exit For
End If
End Try
Loop
Count += 1
prgGenerate.Increment(1)
Next
但这会使我的程序崩溃并使用大量 RAM。
在这个过程中我什么都不能显示,例如:Elapsed Time。而且计时器永远不会启动。
抱歉英语不好。
【问题讨论】:
-
你需要把那个“工作”放到不同的线程中。看看使用 BackgroundWorker() 控件。另外,Timer 实际上在做什么?...
-
计算秒数..我用它来获取经过的时间。
标签: vb.net image for-loop process generator