/// <summary>
        /// The main entry point for the application.
        /// </summary>
        public void Main()
        {

            Paths = new SpringPaths(Path.Combine(sitePath, "autoregistrator"), false);
            Scanner = new SpringScanner(Paths) { UseUnitSync = true, WatchingEnabled = false};

            Scanner.LocalResourceAdded += (s, e) => Trace.TraceInformation("Autoregistrator new resource found: {0}", e.Item.InternalName);
            Scanner.LocalResourceRemoved += (s, e) => Trace.TraceInformation("Autoregistrator Resource removed: {0}", e.Item.InternalName);

            SpringScanner.MapRegistered += (s, e) => Trace.TraceInformation("Autoregistrator Map registered: {0}", e.MapName);
            SpringScanner.ModRegistered += (s, e) => Trace.TraceInformation("Autoregistrator Mod registered: {0}", e.Data.Name);


            Downloader = new PlasmaDownloader.PlasmaDownloader(Scanner, Paths);
            Downloader.DownloadAdded += (s, e) => Trace.TraceInformation("Autoregistrator Download started: {0}", e.Data.Name);
            Downloader.GetResource(DownloadType.ENGINE, MiscVar.DefaultEngine)?.WaitHandle.WaitOne(); //for ZKL equivalent, see PlasmaShared/GlobalConst.cs
            Scanner.InitialScan();

            Downloader.PackageDownloader.SetMasterRefreshTimer(20);
            Downloader.PackagesChanged += Downloader_PackagesChanged;
            Downloader.PackageDownloader.LoadMasterAndVersions()?.Wait();
            Downloader.GetResource(DownloadType.MOD, "zk:stable")?.WaitHandle.WaitOne();
            Downloader.GetResource(DownloadType.MOD, "zk:test")?.WaitHandle.WaitOne();

            lastStableVersion = Downloader.PackageDownloader.GetByTag("zk:stable").InternalName;

            foreach (var ver in Downloader.PackageDownloader.Repositories.SelectMany(x => x.VersionsByTag).Where(x => x.Key.StartsWith("spring-features")))
            {
                Downloader.GetResource(DownloadType.UNKNOWN, ver.Value.InternalName)?.WaitHandle.WaitOne();
            }

            Scanner.Start(false);

            while (Scanner.GetWorkCost() > 0) Thread.Sleep(1000);
        }
        private static void ScanArchives(SpringPaths paths) {
            using (var scanner = new SpringScanner(paths) { UseUnitSync = false })
            {
                scanner.InitialScan();
                scanner.Start();

                while (scanner.GetWorkCost() > 0)
                {
                    Trace.TraceInformation("Waiting for scanner to complete");
                    Thread.Sleep(5000);
                }
            }
        }