diff options
author | Gonzalo Paniagua Javier <gonzalo.mono@gmail.com> | 2004-03-26 02:45:44 +0300 |
---|---|---|
committer | Gonzalo Paniagua Javier <gonzalo.mono@gmail.com> | 2004-03-26 02:45:44 +0300 |
commit | 77338acee6de04e98f9b3693393e1ec41794f6d2 (patch) | |
tree | a2d546d3ab6cc1f456d1895b9ae41a560189d586 /mcs/class/System/System.Diagnostics | |
parent | e5cfa4874dfd2b612a74a20db3f67c9c73eb9a7b (diff) |
2004-03-25 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* Process.cs: use the ISynchronizeInvoke object to invoke the event.
Implemented Close, CloseMainWindow and Kill.
svn path=/trunk/mcs/; revision=24622
Diffstat (limited to 'mcs/class/System/System.Diagnostics')
-rw-r--r-- | mcs/class/System/System.Diagnostics/ChangeLog | 5 | ||||
-rwxr-xr-x | mcs/class/System/System.Diagnostics/Process.cs | 60 |
2 files changed, 47 insertions, 18 deletions
diff --git a/mcs/class/System/System.Diagnostics/ChangeLog b/mcs/class/System/System.Diagnostics/ChangeLog index b6d3157b7ab..5be53f98981 100644 --- a/mcs/class/System/System.Diagnostics/ChangeLog +++ b/mcs/class/System/System.Diagnostics/ChangeLog @@ -1,3 +1,8 @@ +2004-03-25 Gonzalo Paniagua Javier <gonzalo@ximian.com> + + * Process.cs: use the ISynchronizeInvoke object to invoke the event. + Implemented Close, CloseMainWindow and Kill. + 2004-03-23 Ben Maurer <bmaurer@users.sourceforge.net> * Switch.cs: Don't throw when there is no switches section. diff --git a/mcs/class/System/System.Diagnostics/Process.cs b/mcs/class/System/System.Diagnostics/Process.cs index 83a18fe744c..3d0c0369df2 100755 --- a/mcs/class/System/System.Diagnostics/Process.cs +++ b/mcs/class/System/System.Diagnostics/Process.cs @@ -2,11 +2,13 @@ // System.Diagnostics.Process.cs // // Authors: -// Dick Porter (dick@ximian.com) -// Andreas Nahr (ClassDevelopment@A-SoftTech.com) +// Dick Porter (dick@ximian.com) +// Andreas Nahr (ClassDevelopment@A-SoftTech.com) +// Gonzalo Paniagua Javier (gonzalo@ximian.com) // // (C) 2002 Ximian, Inc. // (C) 2003 Andreas Nahr +// (c) 2004 Novell, Inc. (http://www.novell.com) // using System; @@ -38,6 +40,7 @@ namespace System.Diagnostics { IntPtr process_handle; int pid; bool enableRaisingEvents; + ISynchronizeInvoke synchronizingObject; /* Private constructor called from other methods */ private Process(IntPtr handle, int id) { @@ -58,7 +61,6 @@ namespace System.Diagnostics { } } - [MonoTODO] [DefaultValue (false), Browsable (false)] [MonitoringDescription ("Check for exiting of the process to raise the apropriate event.")] public bool EnableRaisingEvents { @@ -360,7 +362,7 @@ namespace System.Diagnostics { [MonoTODO] [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)] - [MonitoringDescription ("The amount of processing time spent is the OS core for this process.")] + [MonitoringDescription ("The amount of processing time spent in the OS core for this process.")] public TimeSpan PrivilegedProcessorTime { get { return(new TimeSpan(0)); @@ -488,15 +490,11 @@ namespace System.Diagnostics { } } - [MonoTODO] [DefaultValue (null), Browsable (false)] [MonitoringDescription ("The object that is used to synchronize event handler calls for this process.")] public ISynchronizeInvoke SynchronizingObject { - get { - return(null); - } - set { - } + get { return synchronizingObject; } + set { synchronizingObject = value; } } [MonoTODO] @@ -544,13 +542,30 @@ namespace System.Diagnostics { } } - [MonoTODO] - public void Close() { + public void Close() + { + Dispose (true); } - [MonoTODO] - public bool CloseMainWindow() { - return(false); + [MethodImplAttribute(MethodImplOptions.InternalCall)] + extern static bool Kill_internal (IntPtr handle, int signo); + + /* int kill -> 1 KILL, 2 CloseMainWindow */ + bool Close (int signo) + { + if (process_handle == IntPtr.Zero) + throw new SystemException ("No process to kill."); + + int exitcode = ExitCode_internal (process_handle); + if (exitcode != 259) + throw new InvalidOperationException ("The process already finished."); + + return Kill_internal (process_handle, signo); + } + + public bool CloseMainWindow () + { + return Close (2); } [MonoTODO] @@ -637,8 +652,9 @@ namespace System.Diagnostics { throw new NotImplementedException(); } - [MonoTODO] - public void Kill() { + public void Kill () + { + Close (1); } [MonoTODO] @@ -865,8 +881,16 @@ namespace System.Diagnostics { protected void OnExited() { - if (Exited != null) + if (Exited == null) + return; + + if (synchronizingObject == null) { Exited (this, EventArgs.Empty); + return; + } + + object [] args = new object [] {this, EventArgs.Empty}; + synchronizingObject.BeginInvoke (Exited, args); } class ProcessWaitHandle : WaitHandle |