Browse Source

处理程序打开中未更新的情况

章政 7 năm trước cách đây
mục cha
commit
2bbb55af8e
1 tập tin đã thay đổi với 16 bổ sung0 xóa
  1. 16 0
      UAS_AutoUpdate/CheckUpdateWindow.cs

+ 16 - 0
UAS_AutoUpdate/CheckUpdateWindow.cs

@@ -47,6 +47,22 @@ namespace UAS_AutoUpdate
             //进行版本的比较
             if (ver1 > ver2)
             {
+                Process[] pro = Process.GetProcessesByName("UAS_MES");
+                if (pro.Length > 0)
+                {
+                    string CloseProcess = MessageBox.Show(this.ParentForm, "当前程序仍在运行,是否关闭", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
+                    if (CloseProcess == "Yes")
+                    {
+                        for (int i = 0; i < pro.Length; i++)
+                        {
+                            Process.GetProcessById(pro[i].Id).Kill();
+                        }
+                    }
+                    else
+                    {
+                        return;
+                    }
+                }
                 wc.DownloadProgressChanged += Wc_DownloadProgressChanged;
                 wc.DownloadFileAsync(new Uri(GetCacheData(ConfigFile, "UpdatePath").ToString()), "UAS_MES.zip");
                 SetCacheData(ConfigFile, "Version", ver1.ToString());