.NET Trivia
Here’s a fun piece of .NET trivia involving thread aborts and exception handling. What does the following code do? And why does it do it?
using System;
using System.Threading;
class TATest
{
public static void Main(string []args)
{
try
{
Console.WriteLine("Aborting!");
Thread.CurrentThread.Abort();
}
finally
{
if((Thread.CurrentThread.ThreadState & ThreadState.AbortRequested)!=0)
{
Console.WriteLine("Aborted!");
Thread.ResetAbort();
}
}
Console.WriteLine(“Bye bye!“);
}
}
(In writing this I've discovered my fingers really prefer to type byte over bye... that t just seems so natural to come next).b
Comments
- Anonymous
May 13, 2004
Dino :
I have made aan attempt to answer your trivia at http://visual-basic-data-mining.net/blogs/KingsleyTagbo/archive/2004/05/13/149.aspx - Anonymous
May 13, 2004
The comment has been removed - Anonymous
May 13, 2004
The comment has been removed - Anonymous
May 14, 2004
The comment has been removed - Anonymous
June 13, 2008
PingBack from http://armani.picturesiteworld.com/trivianet.html