.net application.restart() 系统实现自动重启
2011-01-20 14:10
786 查看
花了整整一天的时间,才研究出来这个系统自动重启时好时坏的问题。
应用.net自带的Application.Restart();有时候重新启动好用,而有时就是起不来,查找了好多相关的资料,都没能尝试成功。但不管怎样我觉得这个说的还算是对我有用粘贴过来。
If Application.Restart is called from any thread in a normally run Windows Forms application, the application shuts down and restarts. In a ClickOnce deployed application, this can be used to cause the application to restart after an update has been downloaded using the ApplicationDeployment class. However, if you call Application.Restart from a non-UI thread (i.e a thread pool thread in the BackgroundWorker.DoWork event), the application is shut down but not restarted.
感觉网上很不赞成应用Application.Restart();方法的,因为,可能导致它不好用的原因很多,会很莫名其妙,但是系统确实就有这样的需求,因此,只能不得已而为之。
这次解决的办法,我总结主要是这个原因,在系统要求自动重启的时候,首先要关闭原有的所有进程,但是重启的这个方法,会因为在没有完全关闭的时候就启动,这样方法本身冲突发生异常就会被关闭,因此,重新启动失败。最后,将Program中的启动线程挂起1.2秒,问题便解决了。
应用.net自带的Application.Restart();有时候重新启动好用,而有时就是起不来,查找了好多相关的资料,都没能尝试成功。但不管怎样我觉得这个说的还算是对我有用粘贴过来。
If Application.Restart is called from any thread in a normally run Windows Forms application, the application shuts down and restarts. In a ClickOnce deployed application, this can be used to cause the application to restart after an update has been downloaded using the ApplicationDeployment class. However, if you call Application.Restart from a non-UI thread (i.e a thread pool thread in the BackgroundWorker.DoWork event), the application is shut down but not restarted.
感觉网上很不赞成应用Application.Restart();方法的,因为,可能导致它不好用的原因很多,会很莫名其妙,但是系统确实就有这样的需求,因此,只能不得已而为之。
这次解决的办法,我总结主要是这个原因,在系统要求自动重启的时候,首先要关闭原有的所有进程,但是重启的这个方法,会因为在没有完全关闭的时候就启动,这样方法本身冲突发生异常就会被关闭,因此,重新启动失败。最后,将Program中的启动线程挂起1.2秒,问题便解决了。
相关文章推荐
- .net application.restart() 系统实现自动重启
- 通用权限管理系统组件 (GPM - General Permissions Manager) 中实现高性能的ASP.NET管理页面自动生成
- (转载整理)程序安装流程及如何实现文件在系统后自动重启(windows)
- 利用cron实现linux系统自动重启
- 实现系统重启自动挂载分区
- 系统下实现电脑服务器自动重启
- ASP.NET 实现重启系统或关机
- linux下为系统添加新模块,并实现重启时自动加载
- Windows XP/2003 实现系统自动登录,自动重启
- 通用权限管理系统组件 (GPM - General Permissions Manager) 中实现高性能的ASP.NET管理页面自动生成
- [VB.NET]请问高手如何用VB2005调用系统默认连接实现自动拨号,谢谢!
- 通用权限管理系统组件 (GPM - General Permissions Manager) 中实现高性能的ASP.NET管理页面自动生成
- 异构SOA系统架构之Asp.net实现(兼容dubbo)
- 如何将asp.net MVC2项目升级为MVC3项目(微软官方自动升级工具:ASP.NET MVC 3 Application Upgrader )
- Android 系统自动重启Bug(高通平台)
- 自动排班系统2.0(基于网络流实现的排班系统,附详细注解)
- 软件运行时候自动下载木马,恶意扣费,篡改手机系统,怎么实现?
- Asp.net 2.0 自定义控件开发[实现自动计算功能(AutoComputeControl)][示例代码下载]
- 轻松实现asp.net中遍历cookies,session,application,小总结
- ASP.NET中实现中文简/繁体自动转换的类