OSDN Git Service

AppliStation-GUI,r905の対策が効かない場合の対策。
authorttp <ttp@users.sourceforge.jp>
Sun, 25 May 2008 03:19:45 +0000 (03:19 +0000)
committerttp <ttp@users.sourceforge.jp>
Sun, 25 May 2008 03:19:45 +0000 (03:19 +0000)
 * 親フレームのEnabled変更を必要あれば別スレッドで

git-svn-id: http://localhost/svn/AppliStation/trunk@916 34ed2c89-c49f-4a4b-abdb-c318350108cf

AppliStation/PackageListViewForm.cs

index a0eb691..c19d932 100644 (file)
@@ -363,9 +363,9 @@ namespace AppliStation
                \r
                public void installRunasActionInvoke(Package[] pkgs)\r
                {\r
-                       this.Enabled = false;\r
+                       this.setWindowEnabled(false);\r
                        \r
-                       string tmpfileName = System.IO.Path.GetTempFileName();\r
+                       string tmpfileName = Path.GetTempFileName();\r
                        try {\r
                                NaGet.Utils.PutSerializeObject(tmpfileName, pkgs);\r
                                \r
@@ -381,7 +381,7 @@ namespace AppliStation
                                hProc.Exited += delegate(object sender, EventArgs e) {\r
                                        pkgListsMan.LoadPackageLists();\r
                                        \r
-                                       this.Enabled = true;\r
+                                       this.setWindowEnabled(true);\r
                                        this.BringToFront();\r
                                        \r
                                        if (File.Exists(tmpfileName)) {\r
@@ -394,7 +394,7 @@ namespace AppliStation
                                if (File.Exists(tmpfileName)) {\r
                                        File.Delete(tmpfileName);\r
                                }\r
-                               this.Enabled = true;\r
+                               this.setWindowEnabled(true);\r
                        }\r
                }\r
                \r
@@ -412,10 +412,10 @@ namespace AppliStation
                }\r
                \r
                internal void uninstallRunasActionInvoke(InstalledPackage[] pkgs)\r
-               {\r
-                       this.Enabled = false;\r
+               {                       \r
+                       this.setWindowEnabled(false);\r
                        \r
-                       string tmpfileName = System.IO.Path.GetTempFileName();\r
+                       string tmpfileName = Path.GetTempFileName();\r
                        try {\r
                                NaGet.Utils.PutSerializeObject(tmpfileName, pkgs);\r
                                \r
@@ -431,7 +431,7 @@ namespace AppliStation
                                hProc.Exited += delegate(object sender, EventArgs e) {\r
                                        pkgListsMan.LoadPackageLists();\r
                                        \r
-                                       this.Enabled = true;\r
+                                       this.setWindowEnabled(true);\r
                                        this.BringToFront();\r
                                        \r
                                        if (File.Exists(tmpfileName)) {\r
@@ -441,10 +441,10 @@ namespace AppliStation
                        } catch (System.ComponentModel.Win32Exception ex) {\r
                                MessageBox.Show(ex.Message, "\83A\83\93\83C\83\93\83X\83g\81[\83\8b", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
                                \r
+                               this.setWindowEnabled(true);\r
                                if (File.Exists(tmpfileName)) {\r
                                        File.Delete(tmpfileName);\r
                                }\r
-                               this.Enabled = true;\r
                        }\r
                }\r
                \r
@@ -462,10 +462,7 @@ namespace AppliStation
                                InstalledPackage[] instPkgs = new InstalledPackage[]{confirm.UninstallPackage};\r
                                \r
                                if (confirm.UseRunas) {\r
-                                       this.Enabled = false;\r
                                        uninstallRunasActionInvoke(instPkgs);\r
-                                       this.Enabled = true;\r
-                                       this.Focus();\r
                                } else {\r
                                        uninstallActionInvoke(instPkgs);\r
                                }\r
@@ -589,9 +586,7 @@ namespace AppliStation
                                Package[] instPkgs = confirm.CheckedPackages;\r
                                \r
                                if (confirm.UseRunas) {\r
-                                       this.Enabled = false;\r
                                        installRunasActionInvoke(instPkgs);\r
-                                       this.Enabled = true;\r
                                } else {\r
                                        installActionInvoke(instPkgs);\r
                                }\r
@@ -618,6 +613,23 @@ namespace AppliStation
                                \r
                                return pkgs.ToArray();\r
                }\r
+               \r
+               /// <summary>\r
+               /// \8e©\83E\83B\83\93\83h\83E\82Ì\97L\8cø\96³\8cø(Enabled)\82ð(\95K\97v\82 \82ê\82ÎInvoke\82µ\82Ä)\8eÀ\8ds\82·\82é \r
+               /// </summary>\r
+               /// <param name="enabled">\97L\8cø\82©\94Û\82©\81BEnabled\82Ì\92l\82É\93ü\82ê\82ç\82ê\82é</param>\r
+               private void setWindowEnabled(bool enabled)\r
+               {\r
+                       MethodInvoker process = (MethodInvoker) delegate() {\r
+                               this.Enabled = enabled;\r
+                       };\r
+                       \r
+                       if (InvokeRequired) {\r
+                               Invoke(process);\r
+                       } else {\r
+                               process.Invoke();\r
+                       }\r
+               }\r
        }\r
 \r
 }\r