//立即更新 private void btnUpdate_Click(object sender, RoutedEventArgs e) { this.Hide(); MainWindow mainWindow = new MainWindow(); mainWindow.ShowDialog(); this.Close(); }
void _backWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { //如果是正常完成,进入安装界面 if (_isNormal) { this.Hide(); MainWindow mw = new MainWindow(); mw.ShowDialog(); } NamedPipeClientHelper.Close(); this.Close(); }
protected override void OnStartup(StartupEventArgs e) { //后台提示更新 if (e.Args != null && e.Args.Length != 0 && e.Args[0] == "backPrompt") { BackPromptWindow promptWindow = new BackPromptWindow(); promptWindow.ShowDialog(); } else { bool isDowanloaded = CheckUpdateHelper.IsDownloaded(); bool isMustUpdate = CheckUpdateHelper.IsMustUpdate(); //如果下载完成 if (isDowanloaded) { //如果是强制更新 if (isMustUpdate) { MainWindow mw = new MainWindow(); mw.ShowDialog(); } //如果不是强制更新 else { UpdatePromptWindow upw = new UpdatePromptWindow(); upw.ShowDialog(); } } //如果未下载完成 else { //如果是强制更新 if (isMustUpdate) { WaitDownloadWindow wdw = new WaitDownloadWindow(); wdw.ShowDialog(); } //如果不是强制更新 else { //启动MVP客户端 string clientPath = AppDomain.CurrentDomain.BaseDirectory + ConfigurationManager.AppSettings["ClientApp"]; System.Diagnostics.Process clientApp = new System.Diagnostics.Process { StartInfo = { FileName = clientPath } }; clientApp.Start(); } } } }
//下载安装 private void btnInstall_Click(object sender, RoutedEventArgs e) { //检查客户端程序是否正在运行 string clientApp = ConfigurationManager.AppSettings["ClientApp"]; var clientPros = ProcessHelper.GetCurrentUserProcess(Path.GetFileNameWithoutExtension(clientApp)); //如果客户端正在运行,关闭客户端 if (clientPros != null && clientPros.Count != 0) { foreach (var client in clientPros) { client.Kill(); } } //启动更新程序 this.Hide(); MainWindow mainWindow = new MainWindow(); mainWindow.ShowDialog(); }