In my experience, Thread.Abort() does not break a thread that is waiting on
some blocking I/O operation. The documentation states that
Thread.Interrupt() is used to bring a thread out of the "Wait/Sleep/Join"
state. I believe the "Wait/Sleep/Join" state is the one that the thread is
in when it is waiting on a network socket. As I understand the
documentation, Thread.Abort() will throw a ThreadAbortedException as soon
as the thread is next running. Thread.Interrupt() will throw a
ThreadInterruptedException if and only if the thread is currently waiting
on I/O, sleeping, or joining with another thread (otherwise it does
nothing). Anyway, when I really want to kill a thread, I do .Interrupt()
*and* .Abort(), and when I want to make sure a program exits, I use
Environment.Exit(exit_code).

Jonathan

At 12:31 AM 16/03/2004 -0800, you wrote:
>Thread.Abort () is what you're looking for.
>
>Alternatively you can switch to using asynchronous IO if you're interested
>in exploring a whole new world of weird and wonderful debugging scenarios.
>
>Piers.
>
>-----Original Message-----
>From: [EMAIL PROTECTED]
>[mailto:[EMAIL PROTECTED] On Behalf Of Antonio Mart��ez
>�lvarez
>Sent: Monday, March 15, 2004 1:01 PM
>To: Mono-List
>Subject: [Mono-list] About killing a thread.
>
>Hello.
>
>How do I kill a thread?
>I have a thread which is always listing a tcp port (blocked), and I want it
>to termitate when the application exit.
>
>Thanks
>
>--
>Antonio Martínez
>_______________________________________________
>Mono-list maillist  -  [EMAIL PROTECTED]
>http://lists.ximian.com/mailman/listinfo/mono-list
>
>
>_______________________________________________
>Mono-list maillist  -  [EMAIL PROTECTED]
>http://lists.ximian.com/mailman/listinfo/mono-list
>
>
_______________________________________________
Mono-list maillist  -  [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list

Reply via email to