0

I have an application written in C# by using the XNA framework. So, it's basically built as a game with Update() and Draw(), and another thing is that this application is meant for running continuously without stopping.

The thing is that I want to do an autoupdate while running. By this, I mean the following thing: I have the application running, and I have a function that checks all the time for other versions of my application(changes that I do to my app and rebuild them in a new release version)

How can I make function that updates to another version which is within a specified folder. It checks whether that folder contains or not a zip archive with the new release of the project, it unzips it and shuts down the current application and starts the new version of the application from the given zip archive. Can you give me a starting point for this problem?

Simon
  • 4,999
  • 21
  • 69
  • 97

1 Answers1

2

I'd do other app that manages that... like a watch dog

this app will check the folder and restart the main app, and should can be configured to ask for restarting or not, and to do the restart in a time range... (¿everyday at 12:00 pm?)

To kill a process:

Process []pArry = Process.GetProcesses();

foreach(Process p in pArry)
{       
    if (p.ProcessName.CompareTo("yourapp") ==0)
    {
       p.Kill();
       break; 
    }
}
p.WaitForExit(); // This is blocking so be careful, maybe it should be run in other thread

To start a process:

Process.Start(path);

You should be aware that the flow of your application should be:

  1. Is a good time to patch the app?
     1.1 NO-> Sleep for some time to recheck (¿12h?) and goto 1
  2. Is there a new path?
     2.1 NO-> Goto 1.1
  3. Kill the main process
  4. Apply the patch
  5. Restart app
  6. Goto 1 
Blau
  • 5,742
  • 1
  • 18
  • 27
  • Can you please give me a link for this sort of app, watch dog? Or something to start with? And another question is if I can stop the current app, and start a new instance of the app, but by using the one in the given archive file which I mentioned in the question body. Would this be possible? – Simon Jun 18 '12 at 08:15
  • Killing the main process is a bit of a sledgehammer - it would probably be better to use some IPC mechanism to ask it to exit gracefully, and only use the kill code if it fails to respond in a reasonable timescale. – Damien_The_Unbeliever Jun 18 '12 at 09:32