Ejemplo n.º 1
0
        public void Run()
        {
            string updateBasePath = Path.Combine(_appBasePath, "patch");

            if (Directory.Exists(updateBasePath))
            {
                Directory.Delete(updateBasePath);
            }

            string localManifestFilePath = Path.Combine(_appBasePath, "manifest.xml");

            Thread t = new Thread(async() => {
                Manifest manifest;
                while (true)
                {
                    if (!File.Exists(localManifestFilePath))
                    {
                        await DownloadManifest(localManifestFilePath);
                    }

                    manifest = GetManifest(localManifestFilePath);
                    if (manifest == null)
                    {
                        File.Delete(localManifestFilePath);
                        continue;
                    }

                    while (true)
                    {
                        if (_versionChecker.IsNewVersionAvailable(manifest))
                        {
                            _updater.UpdateApp(manifest, _appBasePath, updateBasePath);
                            break; // we need to load new version of manifest
                        }
                        Thread.Sleep(60000 * 5);
                    }
                }
            });

            t.IsBackground = true;
            t.Start();

            t.Join();

            mutex.ReleaseMutex();
        }