[Mono-bugs] [Bug 76251][Maj] New - Thread.Interrupt() doesnt interrupt as in .net

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Tue Sep 27 15:10:13 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 yoschy at gmx.de.

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

--- shadow/76251	2005-09-27 15:10:13.000000000 -0400
+++ shadow/76251.tmp.16845	2005-09-27 15:10:13.000000000 -0400
@@ -0,0 +1,121 @@
+Bug#: 76251
+Product: Mono: Runtime
+Version: 1.1
+OS: GNU/Linux [Other]
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Major
+Component: io-layer
+AssignedTo: dick at ximian.com                            
+ReportedBy: yoschy at gmx.de               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Thread.Interrupt() doesnt interrupt as in .net
+
+A sleeping thread will not be interruted as in .net
+
+Testcode:
+------------------------------------------------------------
+using System;
+using System.Threading;
+
+namespace TestThreadInterrupt
+{
+	/// <summary>
+	/// Zusammenfassung für Class1.
+	/// </summary>
+	class Class1
+	{
+		/// <summary>
+		/// Der Haupteinstiegspunkt für die Anwendung.
+		/// </summary>
+		[STAThread]
+		static void Main(string[] args)
+		{
+			//
+			// TODO: Fügen Sie hier Code hinzu, um die 
+Anwendung zu starten
+			//
+			Thread t1 = new Thread(new ThreadStart(WaitFor));
+			if (t1 != null)
+			{
+				t1.Name = "TestInterript";
+				t1.IsBackground = false;
+				t1.Start();
+				Console.WriteLine("t1 start - ThreadName=
+{0}", t1.Name);
+			}
+
+			string line;
+
+			do
+			{
+				line = Console.ReadLine();
+				//mainThread.Interrupt();
+
+				switch (line)
+				{
+					case "i":	if (t1 != null)
+								{
+								
+	t1.Interrupt();
+								}
+						break;
+				}
+						
+			} 
+			while (line != "q");
+
+			if (t1 != null)
+			{
+				t1.Abort();
+				t1.Join(100);
+			}
+		}
+				
+
+
+		public static void WaitFor()
+		{	
+			do
+			{
+				try
+				{
+					Console.WriteLine("x");
+					Thread.Sleep(Timeout.Infinite);
+					Console.WriteLine("X");
+				}
+				catch(ThreadInterruptedException ex)
+				{
+					Console.WriteLine
+("!!!!!!!!!!!!!!!        thread wakeup          !!!!!");	
+				}
+			}while(true);
+	
+		}
+	}
+}
+--------------------------------------------------------
+
+Steps to reproduce the problem:
+1. Run the code
+2. Enter 'i' to interrupt
+3. 'q' to quit
+
+Actual Results:
+when pressing 'i' nothing, if running with MONO
+
+
+Expected Results:
+interrupting the sleeping thread and print something in the console
+
+
+How often does this happen?
+everytime 
+
+
+Additional Information:


More information about the mono-bugs mailing list