本文介绍了等待进程完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在继续下一行代码之前,有没有办法暂停进程或等待进程完成?
Is there any way to pause a process or wait unitl the process is complete before continuing onto the next line of code?
这是我当前压缩所有 PDF 然后删除的过程.目前,它在压缩完成之前删除文件.有没有办法暂停/等待进程完成?
Here is my current process to zip all PDFs and then delete. Currently, its deleting files before the zipping is complete. Is there a way to pause/wait until the process is complete?
Dim psInfo As New System.Diagnostics.ProcessStartInfo("C:\Program Files\7-Zip\7z.exe ", Arg1 + ZipFileName + PathToPDFs) psInfo.WindowStyle = ProcessWindowStyle.Hidden System.Diagnostics.Process.Start(psInfo) 'delete remaining pdfs For Each foundFile As String In My.Computer.FileSystem.GetFiles("C:\Temp\", FileIO.SearchOption.SearchAllSubDirectories, "*.pdf") File.Delete(foundFile) Next 推荐答案可以使用process.WaitForExit方法
WaitForExit 可以让当前线程等待相关进程退出.
WaitForExit can make the current thread wait until the associated process to exit.
链接:msdn.microsoft/fr-fr/library/system.diagnostics.process.waitforexit(v=vs.80).aspx
更多推荐
等待进程完成
发布评论