Can an app written with .net Compact Framework res

2019-03-21 17:54发布

问题:

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