WPF-在SYSTEM帐户下执行进程时性能低下 [英] WPF - Low performance when process is executed under SYSTEM account

查看:33
本文介绍了WPF-在SYSTEM帐户下执行进程时性能低下的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个WPF应用程序,该应用程序通常在具有管理员权限的本地用户帐户下运行.但是,在某些情况下,该过程由运行在 SYSTEM 帐户下的服务或脚本启动,因此该过程也运行在 SYSTEM 帐户下.

I have a WPF Application that is usually running under a local user account with Administrator rights. However, in certain scenarios, the process is started by a service or script that is running under SYSTEM account and the process is therefore also running under the SYSTEM account.

问题在于,当进程在 SYSTEM 帐户下运行时,会有一些明显的滞后(UI响应速度不是很好).

The issue is that when the process is running under SYSTEM account, there are some noticeable lags (the UI is not very responsive).

我使用perfmon进行了一些挖掘,没有发现任何可疑的内容(CPU没有超载,没有引发异常异常,没有内存泄漏等).我还检查了事件日志,没有发现任何有用的信息(没有警告/错误,只有与系统无关的信息).

I did some digging using perfmon and didn't see anything suspicious (CPU is not overloaded, no unusual exceptions are thrown, no memory leaks, etc ...). I also checked the Event log and didn't find anything usefull (no Warnings / Errors, only unrelated information about the system).

我首先认为这是由于该过程是在模拟环境中执行的,但是即使没有模拟(我使用 PsExec.exe -i -s 在SYSTEM帐户下启动它),也有滞后仍然存在.

I first thought it was due to the process being executed in an Impersonated context, but even without impersonation (I used PsExec.exe -i -s to start it under SYSTEM account), the lags still persists.

您知道这将来自何处吗?
不要犹豫,问您是否需要更多信息,我主要是在寻找一些有助于找到根本原因的想法(明显的解决方法是不要在SYSTEM帐户下启动该过程,但这并不是真正的解决办法).

Any idea where this would come from ?
Do not hesitate to ask if you need more information, I'm mostly looking for some ideas that would help find the root cause (the obvious workaround for this is to not start the process under SYSTEM account but it is not really a fix).

此外,请注意,该应用程序在Windows Embedded Standard(XP SP3)的自定义版本下和带有电容式触摸屏的设备上运行.

Also, note that the application is running under a customized version of Windows Embedded Standard (XP SP3) and on a device with a capacitive touch screen.

我的问题不是我怎么解决这个问题?"但是为什么使用SYSTEM帐户时应用程序运行性能低下.

My question is not "how can I solve this problem ?" but "why is the application running with low performance when under SYSTEM account.

我尝试按照@Sander的建议更改Windows的性能优化设置,但未做任何更改( http://support.microsoft.com/kb/308417 ).

I tried to change Windows's performance optimization settings as @Sander suggested, nothing changed (http://support.microsoft.com/kb/308417).

我还使用此应用程序进行了测试: http://www.kynosarges.org/WpfPerformance.html#Application
在每个帐户下运行该应用程序时,对于第一个GDI +测试,我在SYSTEM帐户下始终可以获得大约两倍的运行时间(它基本上绘制了一个三角形),这使我认为这不受WPF的严格限制.同样,除了执行该流程的帐户外,我没有进行任何更改.

I also did a test using this application: http://www.kynosarges.org/WpfPerformance.html#Application
When running the app under each account, I consistently get running time about twice longer under SYSTEM account for the first GDI+ test (it basically draws a bunch of triangles), which leads me to think this is not strictly WPF limited. Again, I didn't change anything except the account under which the process is executed.

推荐答案

我认为您应该完全绕开该问题.不要提供系统服务的用户界面,而是将您的应用程序分为两部分-一部分将执行实际操作,将以服务的形式运行(在任何有意义的帐户下),另一部分-用户界面-将以普通用户的身份运行过程.

I think you should bypass the issue altogether. Don't give a system service UI, instead divide your application into two parts - one part that will perform the actual actions will run as a service (under whatever account makes sense) and the other - the UI - will run as an ordinary user process.

使用WCF相对容易地在两者之间进行通信.

Use WCF to communicate between the two relatively easily.

它将解决您的性能问题以及解决方案中暴露的许多潜在的安全问题.

It will solve your performance issue, as well as many potential security issues that your solution exposes.

这篇关于WPF-在SYSTEM帐户下执行进程时性能低下的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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