[Mono-list] Threading
Jonathan Stowe
gellyfish@gellyfish.com
Mon, 13 May 2002 15:01:35 +0100 (BST)
On Mon, 13 May 2002, Ian McCullough wrote:
> > From: Dick Porter <dick@ximian.com>
> >
> > On Sun, May 12, 2002 at 01:09:17PM +0100, Jonathan Stowe wrote:
> > > Before I bugzilla this is there anything fundamentally wrong with :
> > >
> > [...]
> > >
> > > I am expecting it to run DoThread() ...
> >
> > It will if you run it enough times...
> >
> > Basically, sometimes Main() exits before DoThread() gets going. It should
> > be waiting for the thread that was started.
> >
> > Please bugzilla this.
>
> Hold up a sec! If I'm correct, this behavior is "By Design." If you want
> the main thread of execution to wait for the other one, you must tell it to.
> The simplest way to do this would be to modify TestThread() to be like this:
>
> public TestThread()
> {
> Console.WriteLine("In Constructor");
> try
> {
>
> Thread th = new Thread(new ThreadStart(DoThread));
> th.Start();
> th.Join();
> }
> catch(Exception e)
> {
> Console.WriteLine("Listening :" + e.ToString());
> }
> }
>
OK. That does what I expected ... except that with csc it does it without
the Join() everytime ...
/J\
--
Jonathan Stowe |
<http://www.gellyfish.com> | This space for rent
|