[Mono-list] Thread.IsAlive on mono 0.23 not working

Pablo Baena pbaena@uol.com.ar
22 Mar 2003 19:26:57 +0000


--=-Wg4ydF0r531ODbKsdWzE
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

I am trying to find out if a thread ended with Thread.IsAlive and it
seems that it doesn't work as expected with mono 0.23. It seems it is
working on CVS, at least the code is there. Does the test below work
with it? Will somebody incorporate the new code in the next mono
release? 

Thank you!

using System;
using System.Threading;

namespace test
{

	class test
	{
		static Thread thr1, thr2;

		static void Main(string[] args)
		{

				thr1 = new Thread (new ThreadStart (threadfunc));
				thr1.Start ();
				thr2 = new Thread (new ThreadStart (threadfunc2));
				thr2.Start ();
		}

		static void threadfunc () 
		{
			int i = 0;
			while (i<2)
			{
				Thread.Sleep(1000);
				i++;
			}

		}

		static void threadfunc2 () 
		{
			int i = 0;
			while (i<4)
			{
				if (thr1 != null && thr1.IsAlive)
					Console.WriteLine("thr1 rnning");
				else
					Console.WriteLine ("thr1 is not running");

				Thread.Sleep (1000);
				i++;
			}
		}
	}
}

-- 
Pablo Baena <pbaena@uol.com.ar>

--=-Wg4ydF0r531ODbKsdWzE
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: 7bit

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/1.1.7">
</HEAD>
<BODY>
I am trying to find out if a thread ended with Thread.IsAlive and it seems that it doesn't work as expected with mono 0.23. It seems it is working on CVS, at least the code is there. Does the test below work with it? Will somebody incorporate the new code in the next mono release? <BR>
<BR>
Thank you!
<PRE>using System;
using System.Threading;

namespace test
{

	class test
	{
		static Thread thr1, thr2;

		static void Main(string[] args)
		{

				thr1 = new Thread (new ThreadStart (threadfunc));
				thr1.Start ();
				thr2 = new Thread (new ThreadStart (threadfunc2));
				thr2.Start ();
		}

		static void threadfunc () 
		{
			int i = 0;
			while (i&lt;2)
			{
				Thread.Sleep(1000);
				i++;
			}

		}

		static void threadfunc2 () 
		{
			int i = 0;
			while (i&lt;4)
			{
				if (thr1 != null &amp;&amp; thr1.IsAlive)
					Console.WriteLine(&quot;thr1 rnning&quot;);
				else
					Console.WriteLine (&quot;thr1 is not running&quot;);

				Thread.Sleep (1000);
				i++;
			}
		}
	}
}</PRE>
<TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
<TR>
<TD>
-- <BR>
Pablo Baena &lt;<A HREF="mailto:pbaena@uol.com.ar">pbaena@uol.com.ar</A>&gt;
</TD>
</TR>
</TABLE>

</BODY>
</HTML>

--=-Wg4ydF0r531ODbKsdWzE--