示例#1
0
        static int Main(string[] args)
        {
            var runApplication = true;

            if (args.Length >= 1 && args[0] == "--update")
            {
                Bootstrap.UpdateTriggered = true;
                runApplication            = false;
            }
            Bootstrap.Populate();
            if (Bootstrap.NeedBootstrap)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                var form = new BootstrapProgressForm();
                Application.Run(form);
                if (form.DialogResult == DialogResult.Cancel)
                {
                    runApplication = false;
                }
            }
            if (runApplication)
            {
                return(Launcher.RunPython(args));
            }
            return(0);
        }
示例#2
0
        public static int Main(string[] args)
        {
            Bootstrap.StatusText += output => Console.WriteLine("bootstrapper: {0}", output);
            var runApplication = true;

            if (args.Length >= 1 && args[0] == "--update")
            {
                Bootstrap.UpdateTriggered = true;
                runApplication            = false;
            }
            Bootstrap.Populate();
            if (Bootstrap.NeedBootstrap)
            {
                using var q   = new BlockingCollection <(long, long)>(new ConcurrentQueue <(long, long)>(), 512);
                using var evt = new System.Threading.AutoResetEvent(false);
                var progressWorker = Task.Run(() =>
                {
                    var sw = new Stopwatch();
                    sw.Start();
                    var lastlen    = 0;
                    var last_print = sw.ElapsedMilliseconds;
                    foreach (var(xferd, total) in q.GetConsumingEnumerable())
                    {
                        var clear_last = "\r" + new string(' ', lastlen) + "\r";
                        if (xferd != -1)
                        {
                            if (xferd == 0 || sw.ElapsedMilliseconds - last_print > 500)
                            {
                                var text = string.Format(" {0} / {1}", Bootstrap.FormatSize(xferd), Bootstrap.FormatSize(total));
                                lastlen  = text.Length;
                                Console.Write(clear_last + text);
                                last_print = sw.ElapsedMilliseconds;
                            }
                        }
                        else
                        {
                            Console.Write(clear_last);
                            evt.Set();
                            last_print = sw.ElapsedMilliseconds;
                        }
                    }
                });
                Bootstrap.DownloadProgress += (transferred, total) => {
                    q.Add((transferred, total));
                    if (transferred == -1)
                    {
                        evt.WaitOne();
                    }
                };
                if (!Bootstrap.PerformBootstrapAsync(default).GetAwaiter().GetResult())