[Mono-list] Bug in Mint : For Multi-Threaded Code
Madhuri Kottamasu
madhuri_kottamasu@yahoo.com
Fri, 1 Mar 2002 15:03:48 -0800 (PST)
I am trying to interpret simple multi-threaded code.
Here is the code:
using System;
using System.Threading;
namespace MultiThreadedApp
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
Class1 c = new Class1();
Thread t = null;
Console.WriteLine("Multi-threaded APP");
for (int i=0; i < 5; i++)
{
if (i % 2 == 0)
{
t = new Thread(new ThreadStart(c.ThreadMethod1));
}
else
t = new Thread(new ThreadStart(c.ThreadMethod2));
t.Start();
}
}
private void ThreadMethod1()
{
Console.WriteLine("This is a thread method1");
}
private void ThreadMethod2()
{
Console.WriteLine("This is a thread method2");
}
}
}
When I have Console.WriteLine called in the main
method before thread has called (mscorlib is
pre-loaded), mint works well.
But if I comment out the line
Console.WriteLine("Multi-threaded APP");
And run mint again, I get the following error:
$ mint test.exe
(process:300): ** WARNING **: Failed to load library
libmonowrapper.dll (monowra
pper)Unhandled exception System.NullReferenceException
A null value was found where an object instance was
required.
Unhandled exception System.NullReferenceException A
null value was found where an object instance was
required.
Unhandled exception System.NullReferenceException A
null value was found where an object instance was
required.
Unhandled exception System.NullReferenceException A
null value was found where an object instance was
required.
#0: 0x00006 callvirt in System.Console::WriteLine
(#0: 0x00006 callvirt in System.Console::WriteLine
(#0: 0x00006 callvirt in System.Console::WriteLine
(#
0: 0x00006 callvirt in System.Console::WriteLine
([00DF7A88] [00DF0A90] [00DF7
A88] [00DF0A90] )
)
)
)
#1: 0x00005 call in
MultiThreadedApp.Class1::ThreadMethod2 (#1: 0x00005 ca
ll in MultiThreadedApp.Class1::ThreadMethod1
(#1: 0x00005 call in
MultiThreadedApp.Class1::ThreadMethod2 (#1: 0x00005
call in MultiThreadedApp
.Class1::ThreadMethod1 ()
)
)
Is this a known error ? Is there a fix available ?
Thanks,
Madhuri
__________________________________________________
Do You Yahoo!?
Yahoo! Greetings - Send FREE e-cards for every occasion!
http://greetings.yahoo.com