快速启动表格 [英] Fast process start of form

查看:72
本文介绍了快速启动表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我有带有Autodesk Design Review组件的Windows窗体.

使用方法form.Show()从其他表单启动此表单时,表单将在大约1s内启动.

当我使用process.Start启动相同的表单时,表单将在大约6秒钟后显示.

也许有人对如何使用process.Start()获得相同的结果(1秒)有任何建议?

Hello,

I have windows form with Autodesk Design Review component inside it.

When this form is launched from other form with method form.Show() form launches in about 1s.

When I launch same form with process.Start, form is shown in about 6 seconds.

Maybe someone has any suggestion on how to achive same result (of 1s) with process.Start()?

推荐答案

您正在尝试比较苹果和桔子. Process.Start要求操作系统设置和配置新的流程并启动应用程序,这需要时间.借助Form.Show,流程已经启动并且应用程序正在运行.
You are trying to compare apples and oranges. Process.Start requires the OS to setup and configure a new process and start the application, this takes time. With Form.Show the process has already been started and the application is running.


很明显,在启动流程时,除了创建所需的表单之外,您还需要做很多事情.为了减少花费的时间,请看一下您的过程在启动时正在做什么.如果框架已经在内存中,则加载新进程和.Net Framework的不可避免的开销很小(一定不超过一秒钟),因此至少需要进行四秒钟的操作除了创建此表单之外.

如果有较重的组件可以后期加载(即在Form.Load事件或加载主表单后生成的单独线程中),请进行调查.当然,这将增加解决方案的复杂性,因此这是一个折衷,并且仍然需要6秒钟才能使用全部功能(需要这些组件的任何东西都无法使用,直到它们出现为止).但这可以帮助更快地向用户显示内容.
Obviously, you are doing lots of things when starting a process other than just creating the form you want. In order to reduce the time that takes, have a look at what your process is doing on startup. The unavoidable overhead of loading a new process and the .Net Framework is minimal (certainly not more than one second) if the Framework is already in memory, as it should be, so there is at least four seconds'' worth of stuff being done in addition to this form being created.

If there are heavy components that can be late-loaded (i.e. in a Form.Load event or separate thread that is spawned after the main form is loaded), look into that. It will increase the complexity of your solution, of course, so it is a tradeoff, and it will still take 6 seconds until the full functionality is available (anything that needs those components can''t work until they''re there). But it can help in getting something displayed to the user faster.


这篇关于快速启动表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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