[Mono-bugs] [Bug 76129][Min] New - Process.Exited event doesn't behave like MS.NET

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Fri Sep 16 18:07:48 EDT 2005


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by carlos at applianz.com.

http://bugzilla.ximian.com/show_bug.cgi?id=76129

--- shadow/76129	2005-09-16 18:07:48.000000000 -0400
+++ shadow/76129.tmp.28362	2005-09-16 18:07:48.000000000 -0400
@@ -0,0 +1,101 @@
+Bug#: 76129
+Product: Mono: Class Libraries
+Version: unspecified
+OS: GNU/Linux [Other]
+OS Details: Gentoo 64bit
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Minor
+Component: System
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: carlos at applianz.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Process.Exited event doesn't behave like MS.NET
+
+On MS.NET is perfectly normal to launch a process or find a process that
+has been launched in the past and just EnableRaising events and then grab
+the Exited event. However on Mono the following exception is thrown:
+
+Unhandled Exception: System.InvalidOperationException: The process is
+already started.
+in <0x0004c> System.Diagnostics.Process:set_EnableRaisingEvents (Boolean
+value)in (wrapper remoting-invoke-with-check)
+System.Diagnostics.Process:set_EnableRaisingEvents (bool)
+
+Here is the code I used on Mono on Linux, if you run it under windows and
+change the process to lets say notepad, it works just fine:
+
+
+=======================================
+
+using System;
+
+namespace ProcessTest
+{
+	/// <summary>
+	/// Summary description for Class1.
+	/// </summary>
+	class Class1
+	{
+		/// <summary>
+		/// The main entry point for the application.
+		/// </summary>
+		[STAThread]
+		static void Main(string[] args)
+		{	
+			System.Diagnostics.Process	p =	new System.Diagnostics.Process();
+			System.Diagnostics.ProcessStartInfo info = new
+System.Diagnostics.ProcessStartInfo("monodevelop");
+			p.StartInfo = info;
+			p.Start();
+			p.EnableRaisingEvents = true;
+			p.Exited +=new EventHandler(p_Exited);
+			Console.WriteLine("Press Enter key to exit.");
+			Console.In.ReadLine();
+		}
+
+		private static void p_Exited(object sender, EventArgs e)
+		{
+			Console.WriteLine("exited");
+		}
+	}
+}
+
+
+==========================================
+
+here is another piece of code I used on windows as well:
+
+using System;
+
+namespace ProcessTest
+{
+	/// <summary>
+	/// Summary description for Class1.
+	/// </summary>
+	class Class1
+	{
+		/// <summary>
+		/// The main entry point for the application.
+		/// </summary>
+		[STAThread]
+		static void Main(string[] args)
+		{	
+			System.Diagnostics.Process[]	p =
+System.Diagnostics.Process.GetProcessesByName("notepad");
+			p[0].EnableRaisingEvents = true;
+			p[0].Exited +=new EventHandler(p_Exited);
+			Console.WriteLine("Press Enter key to exit.");
+			Console.In.ReadLine();
+		}
+
+		private static void p_Exited(object sender, EventArgs e)
+		{
+			Console.WriteLine("exited");
+		}
+	}
+}


More information about the mono-bugs mailing list