Sunday, April 3, 2011

How to reset my C# program (Windows mobile) ?

hi

How I can reset my C# program ?

I want that my program will start again

in Windows mobile

thank's in advance

From stackoverflow
  • There is the Application.Restart method, but it doesn't look like it's supported on the Compact Framework. You could try:

    Application.Exit();
    Application.Run(new MyForm());
    
    Zanoni : Application.Exit() will result in a exit 0 code to the application... Application.Run(new MyForm()) doesn't work after...
    heavyd : Please reread to documentation... http://msdn.microsoft.com/en-us/library/ms157894.aspx "This method does not necessarily force the application to exit."
  • Run:

    ProcessStartInfo s = new ProcessStartInfo();
    s.FileName = Assembly.GetExecutingAssembly().GetName().CodeBase;
    s.UseShellExecute = false;
    Process.Start(s);
    

    And:

    Application.Exit();
    
  • One way is to P/Invoke (or use an existing wrapper) around the CeRunAppAtTime API, schedule your app to launch in a couple of seconds time, and exit. The SDF (www.opennetcf.org/sdf/) has a wrapper for this API.

    Peter

    -- Peter Foot Device Application Development MVP www.peterfoot.net | www.inthehand.com

    From The Internet Archive ( http://web.archive.org/web/20071231144636/http://www.themssforum.com/Compact/application-restart/ ). (I gave up on figuring out why the url parser hates that link)

    See CeRunAppAtTime on MSDN.

    Unlike Zanoni's solution, this will not have two instances of your application running at the same time. It's much uglier, though.

0 comments:

Post a Comment