OSDN Git Service

AppliStation-GUI,インスコ・アンインスコ時かつ「管理者として実行時」に親フレームの表示がフリーズする問題を修正
authorttp <ttp@users.sourceforge.jp>
Sun, 11 May 2008 02:46:37 +0000 (02:46 +0000)
committerttp <ttp@users.sourceforge.jp>
Sun, 11 May 2008 02:46:37 +0000 (02:46 +0000)
git-svn-id: http://localhost/svn/AppliStation/trunk@905 34ed2c89-c49f-4a4b-abdb-c318350108cf

AppliStation/AppliStation.Util/NativeMethods.cs
AppliStation/PackageListViewForm.cs

index f739712..8f091db 100644 (file)
@@ -157,6 +157,35 @@ namespace AppliStation.Util
                \r
                #endregion\r
                \r
                \r
                #endregion\r
                \r
+               #region EnableWindow(\83R\83\81\83\93\83g\83A\83E\83g)\r
+//             /// <summary>\r
+//             /// \8ew\92è\82³\82ê\82½\83R\83\93\83g\83\8d\81[\83\8b(\83E\83B\83\93\83h\83E)\82Ö\82Ì\81A\r
+//             /// \83L\81[\83{\81[\83h\93ü\97Í\82¨\82æ\82Ñ\83}\83E\83X\93ü\97Í\82ð\97L\8cø\89»\82Ü\82½\82Í\96³\8cø\89»\r
+//             /// </summary>\r
+//             /// <param name="control">\91Î\8fÛ\82Ì\83R\83\93\83g\83\8d\81[\83\8b\82Ì\83n\83\93\83h\83\89</param>\r
+//             /// <param name="bEnable">\97L\8cø\82É\82·\82é\82©\96³\8cø\82É\82·\82é\82©\82ð\8ew\92è</param>\r
+//             /// <returns>\92¼\91O\82É\83E\83B\83\93\83h\83E\82ª\96³\8cø\8fó\91Ô\82¾\82Á\82½\8fê\8d\87\82Ítrue\82ð\95Ô\82·</returns>\r
+//             public static bool Control_EnableWindow(Control ctrl, bool bEnable)\r
+//             {\r
+//                     try {\r
+//                             return EnableWindow(ctrl.Handle, bEnable);\r
+//                     } catch {\r
+//                             ctrl.Enabled = bEnable;\r
+//                             return true;\r
+//                     }\r
+//             }\r
+//             \r
+//             /// <summary>\r
+//             /// \8ew\92è\82³\82ê\82½\83R\83\93\83g\83\8d\81[\83\8b(\83E\83B\83\93\83h\83E)\82Ö\82Ì\81A\r
+//             /// \83L\81[\83{\81[\83h\93ü\97Í\82¨\82æ\82Ñ\83}\83E\83X\93ü\97Í\82ð\97L\8cø\89»\82Ü\82½\82Í\96³\8cø\89»\r
+//             /// </summary>\r
+//             /// <param name="control">\91Î\8fÛ\82Ì\83R\83\93\83g\83\8d\81[\83\8b\82Ì\83n\83\93\83h\83\89</param>\r
+//             /// <param name="bEnable">\97L\8cø\82É\82·\82é\82©\96³\8cø\82É\82·\82é\82©\82ð\8ew\92è</param>\r
+//             /// <returns>\92¼\91O\82É\83E\83B\83\93\83h\83E\82ª\96³\8cø\8fó\91Ô\82¾\82Á\82½\8fê\8d\87\82Ítrue\82ð\95Ô\82·</returns>\r
+//             [DllImport("user32.dll")]\r
+//             public static extern bool EnableWindow(IntPtr hWnd, bool bEnable);\r
+               #endregion\r
+                               \r
                [DllImport("user32.dll", CharSet=CharSet.Auto)]\r
                internal static extern IntPtr SendMessage( IntPtr hWnd, UInt32 Msg, UInt32 wParam, UInt32 lParam);\r
                \r
                [DllImport("user32.dll", CharSet=CharSet.Auto)]\r
                internal static extern IntPtr SendMessage( IntPtr hWnd, UInt32 Msg, UInt32 wParam, UInt32 lParam);\r
                \r
index c67ff5b..a2ac143 100644 (file)
@@ -352,10 +352,7 @@ namespace AppliStation
                                Package[] instPkgs = confirm.CheckedPackages;\r
                                \r
                                if (confirm.UseRunas) {\r
                                Package[] instPkgs = confirm.CheckedPackages;\r
                                \r
                                if (confirm.UseRunas) {\r
-                                       this.Enabled = false;\r
                                        installRunasActionInvoke(instPkgs);\r
                                        installRunasActionInvoke(instPkgs);\r
-                                       this.Enabled = true;\r
-                                       this.Focus();\r
                                } else {\r
                                        installActionInvoke(instPkgs);\r
                                }\r
                                } else {\r
                                        installActionInvoke(instPkgs);\r
                                }\r
@@ -366,6 +363,8 @@ namespace AppliStation
                \r
                public void installRunasActionInvoke(Package[] pkgs)\r
                {\r
                \r
                public void installRunasActionInvoke(Package[] pkgs)\r
                {\r
+                       this.Enabled = false;\r
+                       \r
                        string tmpfileName = System.IO.Path.GetTempFileName();\r
                        try {\r
                                NaGet.Utils.PutSerializeObject(tmpfileName, pkgs);\r
                        string tmpfileName = System.IO.Path.GetTempFileName();\r
                        try {\r
                                NaGet.Utils.PutSerializeObject(tmpfileName, pkgs);\r
@@ -376,17 +375,26 @@ namespace AppliStation
                                procInfo.Verb = "runas";\r
                                procInfo.WorkingDirectory = Environment.CurrentDirectory;\r
                                \r
                                procInfo.Verb = "runas";\r
                                procInfo.WorkingDirectory = Environment.CurrentDirectory;\r
                                \r
-                               using (System.Diagnostics.Process hProc = System.Diagnostics.Process.Start(procInfo)) {\r
-                                       hProc.WaitForExit();\r
-                               }\r
-                               \r
-                               pkgListsMan.LoadPackageLists();\r
+                               System.Diagnostics.Process hProc = System.Diagnostics.Process.Start(procInfo);\r
+                               hProc.EnableRaisingEvents = true;\r
+                               hProc.SynchronizingObject = this;\r
+                               hProc.Exited += delegate(object sender, EventArgs e) {\r
+                                       pkgListsMan.LoadPackageLists();\r
+                                       \r
+                                       this.Enabled = true;\r
+                                       this.BringToFront();\r
+                                       \r
+                                       if (File.Exists(tmpfileName)) {\r
+                                               File.Delete(tmpfileName);\r
+                                       }\r
+                               };\r
                        } catch (System.ComponentModel.Win32Exception ex) {\r
                                MessageBox.Show(ex.Message, "\83C\83\93\83X\83g\81[\83\8b", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
                        } catch (System.ComponentModel.Win32Exception ex) {\r
                                MessageBox.Show(ex.Message, "\83C\83\93\83X\83g\81[\83\8b", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
-                       } finally {\r
+                               \r
                                if (File.Exists(tmpfileName)) {\r
                                        File.Delete(tmpfileName);\r
                                }\r
                                if (File.Exists(tmpfileName)) {\r
                                        File.Delete(tmpfileName);\r
                                }\r
+                               this.Enabled = true;\r
                        }\r
                }\r
                \r
                        }\r
                }\r
                \r
@@ -405,6 +413,8 @@ namespace AppliStation
                \r
                internal void uninstallRunasActionInvoke(InstalledPackage[] pkgs)\r
                {\r
                \r
                internal void uninstallRunasActionInvoke(InstalledPackage[] pkgs)\r
                {\r
+                       this.Enabled = false;\r
+                       \r
                        string tmpfileName = System.IO.Path.GetTempFileName();\r
                        try {\r
                                NaGet.Utils.PutSerializeObject(tmpfileName, pkgs);\r
                        string tmpfileName = System.IO.Path.GetTempFileName();\r
                        try {\r
                                NaGet.Utils.PutSerializeObject(tmpfileName, pkgs);\r
@@ -415,17 +425,26 @@ namespace AppliStation
                                procInfo.Verb = "runas";\r
                                procInfo.WorkingDirectory = Environment.CurrentDirectory;\r
                                \r
                                procInfo.Verb = "runas";\r
                                procInfo.WorkingDirectory = Environment.CurrentDirectory;\r
                                \r
-                               using (System.Diagnostics.Process hProc = System.Diagnostics.Process.Start(procInfo)) {\r
-                                       hProc.WaitForExit();\r
-                               }\r
-                               \r
-                               pkgListsMan.LoadPackageLists();\r
+                               System.Diagnostics.Process hProc = System.Diagnostics.Process.Start(procInfo);\r
+                               hProc.EnableRaisingEvents = true;\r
+                               hProc.SynchronizingObject = this;\r
+                               hProc.Exited += delegate(object sender, EventArgs e) {\r
+                                       pkgListsMan.LoadPackageLists();\r
+                                       \r
+                                       this.Enabled = true;\r
+                                       this.BringToFront();\r
+                                       \r
+                                       if (File.Exists(tmpfileName)) {\r
+                                               File.Delete(tmpfileName);\r
+                                       }\r
+                               };\r
                        } 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
                        } 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
-                       } finally {\r
+                               \r
                                if (File.Exists(tmpfileName)) {\r
                                        File.Delete(tmpfileName);\r
                                }\r
                                if (File.Exists(tmpfileName)) {\r
                                        File.Delete(tmpfileName);\r
                                }\r
+                               this.Enabled = true;\r
                        }\r
                }\r
                \r
                        }\r
                }\r
                \r