public UpdateForm(UpdateWorker updateWorker) { this.UpdateWorker = updateWorker; InitializeComponent(); this.StartPosition = FormStartPosition.CenterParent; updateWorker.OnUpdateProgress += (obj) => { this.Invoke(new Action(() => { progressBar1.Value = (int)obj; })); }; }
static void Main(string[] args) { string processName = args[0]; //string processName = "应用程序名称"; UpdateWorker updateWorker = new UpdateWorker(); if (updateWorker.IsNeedUpdate()) { ProcessHelper.KillProgressIfExists(processName); //updateWorker.Do(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); UpdateForm updateForm = new UpdateForm(updateWorker); updateForm.ShowDialog(); if (updateForm.DialogResult == DialogResult.OK) { ProcessHelper.StartProgress(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, processName)); } //Application.Run(new UpdateForm(updateWorker)); } }