Managed Space : Jason Whittington's Radio Weblog

Updated: 4/9/2003; 1:47:32 PM.DevelopMentor

 

Subscribe to "Managed Space" in Radio UserLand.

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.

 
 

Wednesday, March 26, 2003
Parody
Posted a "hotel yorba" parody in "Fun Stuff" today. (I wrote it yesterday).
4:07:26 PM      comment []
New C# language features

People have been been asking me about this so...

NEW C# LANGUAGE FEATURES. At OOPSLA late last year, the C# team made a splash by announcing some of the features they'll be adding to the compiler in the next next version of C# (not Everett). This link has that presentation as well as a very nice white paper discussing the new features in detail. [sellsbrothers.com: Windows Developer News]


11:01:48 AM      comment []
Thread.Abort() + finally == scary

Saw an interesting post on the DOTNET-LANGUAGE-DEVS list today that mentioned "interesting" behavior with Thread.Abort().  Calling this function raises an exception in the thread object, which the thread normally can handle prior to shutting down. Nice and clean.  Joe Marshal pointed out a somewhat nasty little race condition, however - if the call to Abort comes out while the thread is executing a finally block the finally block is abandoned (!).  I whipped up this little bit of code to test it out.  Moral of the story - be very careful with Thread.Abort().

using System;
using System.Threading;

class Nasty
{
 static void ThreadProc()
 {
  try
  {
   try
   {
    Console.WriteLine("executing try block");
   }
   finally
   {
    Console.WriteLine("Starting Finally block");

    Thread.Sleep(5000);

    //This line of code will never execute. If someone
    //aborts the thread *while we're in the finally block*
    //the execution of the finally block will be abandoned.

    Console.WriteLine("Done with finally block");
   }
  }
  catch(Exception e)
  {
   Console.WriteLine("Exception caught! {0}", e.GetType());
  }
 }

 static void Main()
 {
  Thread th = new Thread(new ThreadStart(ThreadProc));
  th.Start();

  //These two lines of code crudely guarantee that we
  //will abort the thread while it's in the middle of its
  //finally block.
  Thread.Sleep(1000);
  th.Abort();

  Console.WriteLine("press a key to exit");
  Console.ReadLine();
 }
}


9:23:44 AM      comment []

© Copyright 2003 Jason Whittington.



Click here to visit the Radio UserLand website.

 


March 2003
Sun Mon Tue Wed Thu Fri Sat
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
Feb   Apr

Stuff I recommend:
.NET Resources
COM/C++ Resources
Fun stuff
Stuff I've done:
Windows/COM
.NET
Writings
Conferences

Stuff I read: