views:

321

answers:

1

I need to restart a windows mobile 6 application.

Here is the code I have tried but it just exits and does not restart the app.

public static void RestartApplication()
{
   var fileName = Assembly.GetExecutingAssembly().GetName().CodeBase;
   var startInfo = new ProcessStartInfo
   {
      FileName = fileName,
   };
   Process.Start(startInfo);
   Application.Exit();
}

Thanks!

+2  A: 

You can schedule the OS to run the application in say 10 secs.

CeRunAppAtTime

http://www.rhinomobile.net/2007/03/run-application-at-time-and-time-change.html

http://www.codeproject.com/KB/mobile/WiMoAutostart.aspx?display=PrintAll&fid=1505062&df=90&mpp=25&noise=3&sort=Position&view=Quick&select=2834502

http://windows-tech.info/10/d99ab8a56d1f4818.php

CJCraft.com
Actually you probably can't set it for 10 seconds. The default platform implementation for CeRunAppAtTime requires the time to be more than 11 seconds in the future, otherwise it schedules it iummediately. It's rare that an OEM changes that, so what happens is that it schedules it to happen now, and the second instance tries to start before the calling instance closes.
ctacke