等待进程完成

编程入门 行业动态 更新时间:2024-10-06 18:28:00
本文介绍了等待进程完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在继续下一行代码之前,有没有办法暂停进程或等待进程完成?

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

更多推荐

等待进程完成

本文发布于:2023-11-13 02:49:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1583222.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:进程

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!