コード例 #1
0
        public void CheckUpdate()
        {
            if (backgroundWorkerUpdate.IsBusy)
            {
                return;
            }

            SoftUpdateManager app = new SoftUpdateManager(Application.ExecutablePath, "SCSystem");

            try
            {
                if (app.IsUpdate)
                {
                    if (MessageBox.Show("检查到新版本,是否下载更新包?", "Update", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        this.circularProgressUpdate.Visible   = true;
                        this.circularProgressUpdate.IsRunning = true;

                        backgroundWorkerUpdate.WorkerSupportsCancellation = true; // 设置可以取消
                        backgroundWorkerUpdate.RunWorkerAsync(app);
                    }
                }
                else
                {
                    MessageBox.Show("未找到合适更新包");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                CLog4net.LogError("CheckUpdate" + ex);
            }
        }
コード例 #2
0
        private void backgroundWorkerUpdate_DoWork(object sender, DoWorkEventArgs e)
        {
            SoftUpdateManager sum = e.Argument as SoftUpdateManager;

            sum.Update();
        }