Can an app written with .net Compact Framework restart itself?

我的梦境 提交于 2020-01-01 03:31:07

问题


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.

Of course, I could have 2 .exe: one that updates and the actual app, but I would rather just have one.


回答1:


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);

If you want to do it manually, you'd p/invoke CeRunAppAtTime.

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).



来源:https://stackoverflow.com/questions/6131846/can-an-app-written-with-net-compact-framework-restart-itself

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!