[Mono-bugs] [Bug 41197][Maj] New - Thread.ThreadState sometimes returning an empty state

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
Fri, 11 Apr 2003 12:37:37 -0400 (EDT)


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 kuhne@wanadoo.es.

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

--- shadow/41197	Fri Apr 11 12:37:37 2003
+++ shadow/41197.tmp.9257	Fri Apr 11 12:37:37 2003
@@ -0,0 +1,107 @@
+Bug#: 41197
+Product: Mono/Class Libraries
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Major
+Component: CORLIB
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: kuhne@wanadoo.es               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Thread.ThreadState sometimes returning an empty state
+
+Description of Problem:
+-----------------------
+
+Thread.ThreadState sometimes returns an empty state.
+
+Steps to reproduce the problem:
+-------------------------------
+
+1. Run this:
+
+using System;
+using System.Threading;
+                                                                          
+     
+public class Test
+{
+    static Thread thread;
+                                                                          
+     
+    public static void Main()
+    {
+        thread = new Thread(new ThreadStart(ThreadedMethod));
+        Console.WriteLine("Before thread.Start() :");
+        PrintState();
+        thread.Start();
+        Thread.Sleep(1000);
+        Console.WriteLine("While is running :");
+        PrintState();
+        thread.Abort();
+        thread.Join();
+        Console.WriteLine("When has been Aborted :");
+        PrintState();
+    }
+
+    public static void PrintState()
+    {
+        Console.WriteLine("thread.IsRunning? " + thread.IsAlive);
+        Console.WriteLine(
+            "tread.ThreadState = " +
+            thread.ThreadState.ToString() + "\n"
+        );
+    }
+                                                                          
+     
+    public static void ThreadedMethod()
+    {
+        try {
+            Console.ReadLine();
+        } catch (Exception e) {
+            Console.WriteLine(">>>" + e.Message + "<<<\n");
+        }
+    }
+}
+
+2. Wait until program exits.
+
+Actual Results:
+---------------
+
+Before thread.Start() :
+thread.IsRunning? False
+thread.ThreadState = Unstarted
+ 
+While is running :
+thread.IsRunning? True
+thread.ThreadState =
+ 
+>>>Thread was being aborted<<<
+ 
+When has been Aborted :
+thread.IsRunning? True
+thread.ThreadState =
+
+Expected Results:
+-----------------
+
+Before thread.Start() :
+thread.IsRunning? False
+thread.ThreadState = Unstarted
+ 
+While is running :
+thread.IsRunning? True
+thread.ThreadState = !!!!!!!!NOT EMPTY!!!!!!!
+ 
+>>>Thread was being aborted<<<
+ 
+When has been Aborted :
+thread.IsRunning? !!!!!!!!!!!!!FALSE!!!!!!!!!
+thread.ThreadState = !!!!!!!!NOT EMPTY!!!!!!!