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

Piers Haken piersh@friskit.com
Sat, 22 Mar 2003 16:12:09 -0800


As a workaround, try using Thread.Join(0)
=20
Piers.

-----Original Message-----
From: Pablo Baena [mailto:pbaena@uol.com.ar]=20
Sent: Saturday, March 22, 2003 11:27 AM
To: mono list
Subject: [Mono-list] Thread.IsAlive on mono 0.23 not working


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?=20

Thank you!=20
using System;

using System.Threading;



namespace test

{



	class test

	{

		static Thread thr1, thr2;



		static void Main(string[] args)

		{



				thr1 =3D new Thread (new ThreadStart
(threadfunc));

				thr1.Start ();

				thr2 =3D new Thread (new ThreadStart
(threadfunc2));

				thr2.Start ();

		}



		static void threadfunc ()=20

		{

			int i =3D 0;

			while (i<2)

			{

				Thread.Sleep(1000);

				i++;

			}



		}



		static void threadfunc2 ()=20

		{

			int i =3D 0;

			while (i<4)

			{

				if (thr1 !=3D null && thr1.IsAlive)

					Console.WriteLine("thr1
rnning");

				else

					Console.WriteLine ("thr1 is not
running");



				Thread.Sleep (1000);

				i++;

			}

		}

	}

}
--=20
Pablo Baena < pbaena@uol.com.ar <mailto:pbaena@uol.com.ar> > =09