本文介绍了产卵更多新工艺时的Process.Start放缓的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过的Process.Start 启动的进程似乎有大约26秒钟的延迟时衍生的进程(子),推出更多的新进程(孙子 ) - 我试图找到一种方法来解决这个问题。具体来说,这是发生在原工艺(父)是一个ASP.Net网站或Windows服务(都尝试)。

Processes launched via Process.Start seems to have around a 26-second delay when the spawned process (the "child") launches more new processes (the "grandchildren") - I'm trying to find a way to solve this issue. Specifically, this is occurring when the original process (the "parent") is an ASP.Net website or a Windows Service (tried both).

我们正在试图运行服务器端的命令行工具来收集信息,在文件系统进行修改,并继续与其他进程时,子结束了。当创建子直接通过命令行,没有延迟,并具有一定的命令行参数,子不产生新的进程,和没有延迟。然而,与其他参数,子派生孙子(同一个可执行文件本身,但我们不能修改其代码),并似乎有25-30秒(通常26秒)延迟之前的第一道工序是启动,然后运行正常。

We're attempting to run a server-side command-line tool to gather information, make modifications in the file system, and continue with other processes when the "child" is finished. When creating the "child" directly via command-line, there is no delay, and with certain command-line parameters, the "child" does not spawn new processes, and there is no delay. However, with other parameters, the "child" spawns "grandchildren" (the same executable as itself, but we can't modify its code) and seems to have a 25-30 second (usually 26 seconds) delay before the first process is started, and then runs normally.

我试过修改 UseShellExecute 属性,则 CreateNoWindow 属性和 WindowStyle 属性,没有效果。 ErrorDialog RedirectStandard * 属性是假的。

I've tried modifying the UseShellExecute property, the CreateNoWindow property, and the WindowStyle property, to no effect. ErrorDialog and the RedirectStandard* properties are false.

我正在使用的代码如下:使用

The code I'm using is as follows:

using (Process p = new Process())
{
    p.StartInfo = new ProcessStartInfo(exePath, args)
    {
        WorkingDirectory = workingDirectory,
        UseShellExecute = true,
        CreateNoWindow = true,
    };
    p.Start();
    p.WaitForExit();
}



呵呵,我不认为这是重要的我见过的问题其他地方引用(但没有解决方案),但exePath我用点msysgit的git.exe。

Oh, I don't think it matters as I've seen the issue referenced elsewhere (but no solutions), but the exePath I'm using points to msysgit's git.exe.

推荐答案

很难说一个原因是这可能会发生,你需要做进一步的故障排除。

Hard to tell a reason why this might happen, you need to do further troubleshooting.

我会建议你使用进程管理器和Process Monitor来寻找潜在的问题。

I would suggest that you use Process Explorer and Process Monitor to look for potential problems.

我猜想这个问题是不直接在代码更与用户的环境。例如,W3wp.exe进程在非GUI会话(会话0)上运行,用户可能不被配置为拥有Web访问(代理配置),这样你可能会看到这里超时问题。

I would guess that the problem is not directly in your code but more related to the environment of the user. For example, the w3wp.exe process runs in a non-GUI session (session 0) and the user might not be configured to have web access (proxy configuration) so that you might see a timeout issue here.

这篇关于产卵更多新工艺时的Process.Start放缓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 15:35