Process.Start在某些客户端上随机阻止/挂起 [英] Process.Start is blocking/hanging randomly on some clients

查看:55
本文介绍了Process.Start在某些客户端上随机阻止/挂起的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(有一个非常相似的主题从未解决:此处)

(There is a very similar topic that never got solved: here)

我们有一个在多个客户端上运行的大型应用程序,但是最近我的一些代码停止了工作.添加一些调试代码后,我发现代码停止在对Process.Start()的调用(未设置shellexecute = true)上.

We have a big app running on several clients, but recently some of my code stopped working. Adding some debug code I found out the code stops at a call to Process.Start() (with no shellexecute=true set).

通话很简单

 Process.Start(new ProcessStartInfo("program"))    

在BackgroundWorker线程中.

in a BackgroundWorker thread.

程序"应用执行应做的操作并退出.

The "program" app does what it should do and exits.

我们的应用程序继续运行,因为该线程位于后台,但是如果该应用程序运行另一个Process.Start在GUI线程上,则该应用程序将锁定.如果使用X按钮关闭应用程序,则该线程仍被Process.Start阻止,因此该应用程序仍显示在taskmanager中.

Our application continues as the thread is in the background but if the application runs another Process.Start on the GUI thread, the app locks up. If the application is closed with the X button the app still shows in taskmanager as the thread is still blocked by the Process.Start.

问题是无法复制此行为.它在某些客户端计算机上随机发生.

The problem is that this behavior can not be reproduced. It happens randomly on some clients computers.

会使Process.Start()挂起怎么办? (Program.Main标记为[STAThread])

What could happen to make Process.Start() hang? (Program.Main is marked with [STAThread] )

我目前刚刚采取了一种变通方法,即在其自己的线程中启动Process.Start(),如果5秒钟后仍未返回,则将其杀死.但这对于等待代码返回的用户来说是5秒之多(由于某些情况下我需要在Process.Start()上返回值,我不知道可以将超时设置得多么低).

I have currently just made a workaround that launches the Process.Start() in its own thread, killing it after 5 seconds if it has not returned by then. But that is 5 seconds to much for the user waiting for the code to return ( I do not know how low i can set the timeout as I need the return value on Process.Start() in some cases ).

是否可以使用防病毒软件进行干扰? (客户端已安装Symantec AV)

Can there be antivirus softwares interfering? (the clients has Symantec AV installed)

更新:我以为当我做

ProcessStartInfo psi = new ProcessStartInfo("ping", "localhost");

默认情况下psi.UseShellExecute为FALSE ...这是不正确的.默认为TRUE.这正常吗?

that psi.UseShellExecute was FALSE by default... This is not correct. It defaults to TRUE. Is this normal?

推荐答案

我知道此线程有点旧,但是如果有人感兴趣,这是由Shell扩展(在本例中为防病毒软件)引起的.基本上,当您以UseShellExecute = true(默认值)开头时,防病毒软件会干扰Processor.Start并将其挂起(似乎是随机的).有趣的是,该过程开始正常,它是挂起的调用者线程.

I understand this thread is kind of old, but if anyone is interested, this is caused by a shell extension(in this case, the antivirus software). Basically, when you start with UseShellExecute=true(default), the antivirus software interferes with Processor.Start and makes it hang(seems to be random). Interestingly, the process starts just fine, it's the caller thread that hangs.

我们在客户端的一台服务器中启用了Symantec Virus保护时遇到了同样的问题.我们通过在防病毒软件上设置例外来修复它.或者,您可以禁用UseShellExecute.

We had the very same issue with Symantec Virus protection being enabled in one of our client's servers. We fixed it by setting up exceptions on the antivirus software. Alternatively, you can disable UseShellExecute.

这篇关于Process.Start在某些客户端上随机阻止/挂起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆