Search code examples
c#.netxnaauto-update

How to make autoupdate for application while running XNA


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?


Solution

  • 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