为什么Application.Restart()不可靠? [英] Why is Application.Restart() not reliable?

查看:1063
本文介绍了为什么Application.Restart()不可靠?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用方法 Application.Restart()在C#中应重新启动当前应用程序:但似乎这并不总是工作

Using the method Application.Restart() in C# should restart the current application: but it seems that this is not always working.

还有一个原因是对于这一问题,有人可以告诉我,为什么它不工作的所有时间?

Is there a reason for this Issue, can somebody tell me, why it doesn't work all the time?

推荐答案

有可能是一个很大的原因。这并不是说该方法不起作用;相反,很多时候程序员忘记,他们已经把东西在自己的code,它会阻止自动关闭,或启动应用程序。举两个例子:

There could be a lot of reasons for this. It's not that the method doesn't work; rather, many times programmers forget that they've put something in their code that would stop the application from automatically shutting down, or starting up. Two examples:

  • 在窗体上的Closing事件可以停止一个应用程序的停机时
  • 如果你正在做检查一个已经运行的过程中,老人们可以不关闭不够快,让新的启动。

检查$ C $下这样的陷阱。如果您看到在一个空白的应用程序这种行为,那么这是更可能是比你的code中的实际功能有问题。

Check your code for gotchas like that. If you're seeing this behaviour within a blank application, then that's more likely to be a problem with the actual function than your code.

这篇关于为什么Application.Restart()不可靠?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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