Can an app written with .net Compact Framework restart itself?
Can an app written with .net Co开发者_开发知识库mpact 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.
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).
精彩评论