C#应用程序延迟启动注意事项 [英] C# Application Delayed Startup Considerations

查看:113
本文介绍了C#应用程序延迟启动注意事项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序需要从用户登录开始(使用注册表运行键)[谢谢 Dave Kreskowiak ]。



我的问题是:在启动时,应用程序执行许多可能成本高昂的操作,而在慢速计算机上,增加的开销肯定不会被理解。从好的方面来说,我可以将应用程序启动延迟到以后的时间。问题是,您认为从系统启动中减少应用程序开销是一种很好的方法。



想法#1:

I have an application that I need to start on User logon (with a Registry Run key) [Thanks Dave Kreskowiak].

My question is this : on startup, the application performs a number of operations that may be costly, and on slow computers the added overhead will surely not be appreciated. On the bright side I can delay the application startup to a later time. The question is, what do you think would be a good approach to reduce my application overhead from system startup.

Idea #1 :

System.Threading.Thread.Sleep(10000); // How much do you really wait?



是的,我猜这可以完成工作,但我认为这是一个相当肮脏的解决方案,除了硬编码几秒钟(例如10)并不能真正扩展到可能更快/更慢的其他系统。





想法#2:


Yes that could get the job done I guess, but I think it's a rather dirty solution, and besides hardcoding a number of seconds (such as 10) isn't really scalable to other systems that may be faster / slower.


Idea #2 :

Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Low;



这可能有效,但我仍然希望有更好的解决方案,可以延迟应用程序启动,就像你可以选择延迟启动与Windows服务。



谢谢:)


This could maybe work, but I'm still hoping there are better solutions that can delay the application startup, just like you could select Delayed Startup with windows services.

Thanks :)

推荐答案

首先,运行注册表运行键之外的任何内容都不是在Windows启动时。您所指的是在用户登录时。



Windows启动将是一个服务应用程序。



想法#3。使用性能计数器每隔一段时间轮询CPU和硬盘驱动器的使用情况。当它们都低于某个阈值时,启动你的代码。
First of all, running anything out of the Registry Run key is NOT "at Windows startup". What you're referring to is "at user logon".

Windows startup would be a service application.

Idea #3. User the performance counters to poll for CPU and Hard Drive usage every once in a while. When they are both below a certain threshold, kick off your code.


这篇关于C#应用程序延迟启动注意事项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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