问题标签 [waitforexit]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
c# - C# RedirectStandardOutput 输出和 weaitforexit
我有以下情况。我需要使用 Process() 在 c# 中运行一些 bat 文件,并且需要将它的输出结束错误重定向到文件。我知道该怎么做,如果我的进程不使用超时,我的代码可以正常工作。所以程序一直工作到进程结束(我期望的是进程在超时后被杀死)。以下是我的代码。
c# - Visual Studio 调试 - System.Diagnostics.Process 在 WaitForExit 上挂起
在控制台应用程序、Windows 10、Visual Studio 2015、.NET 4.6 中,我在 Main 中调用称为 TestProcess 的单个方法。构建模式调试,如果我在不调试的情况下运行应用程序,它会打印正确的文本:
827ccb0eea8a706c4c34a16891f84e7b *test.txt
按任意键继续 。. .
如果我在调试的情况下运行应用程序,它会在打印前等待 3 秒
错误 假 假 假 '' ''
这只是对实际问题的简化,此代码是一些复杂代码的主干,这些代码在没有调试 md5sums.exe 的情况下也挂在发布中,但适用于其他一些程序。Coplex 代码也挂在var a = proc.WaitForExit(timeout); 直到超时,如附件示例所示。另一方面,这种简化将在没有调试器的版本中起作用。此外,所有这些问题都始于 Windows 10,在 Windows 7 上一切正常。
[编辑] 不明白为什么md5sums.exe会导致问题,如果我使用其他东西,即。FileName = "ping", Arguments = "localhost" 一切都按预期工作。
[EDIT2] 我的复杂程序在 Windows 10 上停止工作(发布 - 不带调试运行),但这个示例也挂在 Windows 7 上(调试 - 带调试运行)
c# - 在进程中执行任务 WaitForExit(n) C#
我正在开发一个简单的控制台应用程序,并尝试在 WaitForExit() 过程中读取用户输入。
arg1 被定义为一个空字符串。问题是我的 WaitForExit 执行但循环内的任何内容都没有执行,因此程序等待 6 秒并继续进行而不要求输入。
我也尝试过类似的东西:
有没有办法通过使用 WaitForExit() 来做到这一点?
c# - Process.Start 等待excel退出错误
这是我的代码:
Excel 打开我请求的文件,但系统在该部分崩溃objProcess.WaitForExit()
。我得到的错误如下:
没有进程与此对象关联。
我希望系统打开模板,让用户添加他/她的数据,保存并关闭 MS Excel。一旦系统检测到进程不再运行,指向sTemplateSharedPath
并将所述更改导入系统。如果在用户编辑 Excel 文档时应用程序的 UI 没有响应,这很好。
在开始该过程之前,我已将以下代码添加到上面的代码中:
但我得到这个错误:
指定的可执行文件不是此操作系统平台的有效应用程序
我确实希望有人能够帮助我解决这个问题。
提前致谢。
c# - C# WPF Kill a Process after x time: IvalidOperationException: Process Terminated
I know, I know, there are many questions and good answers on how to kill a process after x time in C#.
However after reading and writing the code to achieve this task, I find that is impossible to kill a process after a X time. Due to my novice in C#, I find difficult to understand the cause of error and correct it.
The task I want to achieve is to kill a process after 40 minutes, that process is started by a button click. I'm writing to the console:
Of all the answers in SO, this is the generalized accepted answer.
When running the code on VS 2015, the debugger gives me this error: "Can't process the request because the Process is finished." Also always get the same console line: No kill which indicates that WaitForExit is still true. This after waiting more than 10 minutes event the time to kill is set to less than one minute.
So I don't understand: I launched the process but when ordered to kill, it's yet finished?
vb.net - 进程 WaitForExit() 不等待 Windows 资源管理器关闭
下面的代码是我尝试打开 Windows 资源管理器,然后等待用户关闭它,然后继续执行程序。
这适用于 Notepad.exe 而不是 Exlorer.exe
结束子
谢谢你的帮助
c# - C# process.WaitForExit() 不等待(控制台应用程序)
我在 C# 中有以下应用程序。我所期待的是它会打开 calc.exe,等待我手动关闭它(控制台会挂起),然后它最终会退出。但它会打开 calc.exe 并退出(而 calc 仍处于打开状态)。我错过了什么?
从这里复制的代码。
c# - System.Diagnostics.Process ExitCode 1
我正在使用简单的 C# 静态方法来启动 Windows 应用程序。除了 iexplore.exe 之外,所有 32 位或 64 位应用程序都可以正常工作。
当我打电话时:
System.Diagnostics.Process WaitForExit() 方法不等待 iexplore.exe 关闭并且 ExitCode 返回 exitcode=1。
这是 ExecHttp:
我做了很多搜索,唯一的解决方法是在 System.Diagnostic.Process.ProcessStartInfo Arguments 属性上添加 -nomerge 关键字。WaitForExit() 在其他 Windows .exe 进程上工作正常,但不适用于 iexplore.exe 进程。我们如何测试 iexplore.exe 进程的进程状态?
谢谢
c# - Process.StandardOutput.ReadToEnd() 与 Process.WaitForExit()
我有一个 Windows 服务调用控制台应用程序并读取控制台输出以确定状态。
在调用 StandardOutput.ReadToEnd() 后,我在有时间限制的情况下调用 WaitForExit()。
问题是如果控制台应用程序花费的时间超过 WaitForExit() 的时间限制,那么 ReadToEnd() 会阻塞直到可执行文件退出,从而使 WaitForExit() 变得多余?
c# - 如果应用程序是 Microsoft 应用程序,则无法等待退出
我正在开发一个应用程序,即打开一个带有关联应用程序的文件以获取文件扩展名(这部分由 shellexecute 提供),并等待它退出,然后继续处理文件。我知道 Process.Start(...) 可能会返回 null 例如,如果有相同的进程正在运行等。我通过要求用户在继续之前关闭默认应用程序的所有窗口来解决它。我从从 shell32.dll 导入的 FindExecutable(...) 获取关联的 .exe 路径,然后在循环中调用它并检查列表长度是否为 0。
在这里,我遇到了一堵我无法克服的墙。如果默认应用程序是来自 Microsoft(Edge, Photos, Movies) FindExecutable(...) 的任何类型的应用程序,则返回空字符串。但是 Process.Start(...) 以某种方式启动了正确的默认应用程序,例如 Microsoft Edge(for .pdf) 但即使没有 Microsoft Edge 实例正在运行,它也会返回 null,所以我不能等待新创建的进程退出。如果应用程序是微软提供的应用程序,这一切都很好。
我可以以某种方式利用它或重新设计等待退出吗?