用.net Compact Framework编写的应用程序可以重新启动吗? [英] Can an app written with .net Compact Framework restart itself?
问题描述
使用.net Compact Framework编写的应用程序可以自行重启吗?
Can an app written with .net Compact Framework restart itself?
实现此目标的一些常见模式是什么?我希望有一个自我更新的应用程序,如果更新完成,它会自行重启。
What are some of the common patterns to achieve this? I would like to have a self-updating application that restarts itself if update was done.
当然,我可以有2个.exe:一个可以更新和实际应用的.exe,但是我宁愿只有一个。
Of course, I could have 2 .exe: one that updates and the actual app, but I would rather just have one.
推荐答案
绝对。实际上,它比在台式机上更容易实现。如果您使用的是SDF,请使用以下代码:
Absolutely. It's actually way easier to do than on the desktop. If you're using the SDF, use this:
var thisName = Assembly.GetExecutingAssembly().GetName().CodeBase;
var time = DateTime.Now.AddSeconds(11);
Notify.RunAppAtTime(thisName, time);
如果您想手动进行操作,则可以 p /调用CeRunAppAtTime 。
If you want to do it manually, you'd p/invoke CeRunAppAtTime.
请注意,您必须在将来的启动时间大于10(而不是== 10)秒,否则启动将立即发生(有关如何在内核中设置默认通知设置的构件)。
Note that you must have a launch time of > 10 (not >= 10) seconds in the future or the "launch will happen immediately (an artifact of how the default notification setup is set in the kernel).
这篇关于用.net Compact Framework编写的应用程序可以重新启动吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!