Better Know a Framework: System.Environment.FailFast

Ok, a new method on System.Enviroment in .NET 4.0 is the FailFast method. This a new nuclear option for ending your program should it have gone horribly, horribly wrong. There are 2 overloads, one takes a string, the other takes the string and an exception. When the application exits the string and exception details are written the event log and a dump is created for the application.

One thing to note is that NO catch blocks, finalizers or any other form of code will run in the application. This can be a good thing if your finalizers clean up stuff that in bad crashes you would rather was left behind. However, be careful, it means any Dispose methods or Finalizers that release shared or unmanaged resources will also not run.

Its nice they gave us the nuclear option, but we should also be careful how they are used.

This entry was posted in Better Know a Framework. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s