Being Polite Could Get You Killed!

But wouldn't you rather die a gentleman than live as a savage?

--

More British passengers died on the Titanic because they queued politely for lifeboats, researchers believe.

"The American culture was set up to be a more individualist culture and the British culture was more about the gentlemanly behaviour," Mr Savage says.

"You've got to remember that this is the Edwardian period when to be a gentleman was the peak of society."

Mr Savage said: "There was one gentleman who was rather wealthy... who went back downstairs after he put his wife on the [life] boat... put on his tuxedo...went back upstairs and smoked... with the idea that if I am going die, I may as well die as a gentleman and well-dressed."

 

Now THAT is my kind of man! AMEN BROTHER!

Reusable Generic Exception Wrapper in C#

When crossing boundaries between software layers you are sometimes faced with the requirement to wrap a meaningless exception from a lower layer into a more meaningful exception for users from the higher layer. The pattern described below helps with implementing this requirement in a reusable way. It is in no way meant to be a catch-all for every situation where you have to deal with exceptions, but when applied correctly can prove to be an invaluable tool in your toolkit. See Framework Design Guidelines, Chapter 7 (7.2.3) for more one exception wrapping.

The approach used is to wrap the logic that can fail in a delegate and have this delegate executed by the WrapExceptions method. The WrapExceptions method then takes responsibility of handling the exceptions appropriately. It should be modified to handle only the applicable exceptions; some exceptions you might not want to wrap e.g. StackOverflowException, OutOfMemoryException and ThreadAbortException because you cannot recover from them. An added advantage of wrapping the failure prone code in a delegate is that it allows you to easily wrap it around existing code.

The WrapExceptions code snippet:

// public delegate void Action();

public static void WrapExceptions(Action action)

{

   try

   {

      action();

   }

   catch (MyApplicationException)

   {

      // just rethrow exception, it

      // was already properly handled

      throw;

   }

   catch (Exception e)

   {

      throw new MyApplicationException(e);

   }

}

And then you can use it as follows:

public void WrapMyException(string filepath, string myLine)

{

   WrapExceptions(delegate()

   {

      using (TextWriter writer = new StreamWriter(filepath))

      {

         writer.WriteLine(myLine);

      }

   });

}

Let me know your thoughts on this approach. What problems did it solve, and did it introduce new ones?

More pain with NVidia...

It has been a while since I last tried to find a stable video driver and reader Gregg's question made me pull the trigger on another adventure in driver-installation-land. It has been a nightmare!

I started out with trying to reproduce the problem desribed in 'Black Screen after Vista Wakes Up from Sleep with NVidia Driver 7.15.11.7521' by installing the latest NVidia GeForce video driver available: GeForce Release 178 WHQL (Version: 178.24, Release Date: October 15, 2008, Operating System: Windows Vista 32-bit, Language: U.S. English, File Size: 85 MB). A reboot later the version number now was at 7.15.11.7824. A quick cycle through sleep-and-resume confirmed the problem was still there. Ouch! Reader Eddy had spent some time troubleshooting this issue as well and pointed out the resolution played a role in it, I am running in 1280x1024 32 bit color. So I changed the color bits from 32 to 16: problem still there, lowered the resolution to 1152x864: problem gone! (I skipped a number of steps here, if NVidia wants scientific data they can hire me and pay for my precious time). Unfortunately now the screen looks like somebody put Vaseline in my eyes. Yuck!

Ok, so the screen was ugly, but I could go through a sleep-and-resume cycle. Was it worth the ugly screen? Absolutely not! Time to run system restore and get back to my original driver setup...

Unfortunately kicking off system restore to my old restore point presented me with a blue screen during the process.

...

Eventually my system rebooted, Vista prompted me to its awareness of the crash, I sent the crash report and Microsoft pointed the finger at the NVidia SATA driver. Gaaaaa! Oh well, that was fun, I figured I would try system restore again only to find every single restore point had vanished. Automatic, Manual, they are all gone! Somebody pinch me! My screen looks like all pixels are smeared into eachother and I'm stuck with a broken driver setup. Wake me up from this nightmare!

Moving on...

My SATA driver is broken, Microsoft says I need to get latest from NVidia... I figured I could put NVidia to work for me this time and use the wizard from the website to determine the Motherboard software download I needed. The verdict? GeForce 6150LE / nForce 430 (nForce Driver Version 15.24 WHQL, Release Date: September 12, 2008). Sounds good. Download, install, reboot. This installer puts a driver for just about every piece of hardware they created on your system, and as it comes as a package I would expect them to work together very well. (GeForce 6150 LE driver version 7.15.11.7540, SATA driver version 10.3.0.42.) Unfortunately, a 'quick' sleep-and-resume cycle showed the problem was still there and Windows Update tells me there are updated drivers available for my nForce networking and SATA controller.

Installed GeForce 6150LE driver version 178.24 again and rebooted. Worked with the system for a couple of days and on my next reboot I blue-screened again. Installing the latest SATA driver through Windows Update seems to have resolved that issue. But for now I have disabled sleep mode.

Conclusion: Problem still not fixed.

My Latest Track