tags:

views:

1096

answers:

3

What is Environment.FailFast?

How is it useful?

+3  A: 

It's a way to immediately exit your application without throwing an exception.

Documentation is here.

Might be useful in some security or data-critical contexts.

Ed Guiness
+15  A: 

It is used to kill an application, its a static method that will instantly kill an application without being caught by any exception blocks.

Environment.FastFail(String) can actually be a great debugging tool. For example, say you have an application that is just downright giving you some weird output. You have no idea why. You know it's wrong, but there are just no exceptions bubbling to the surface to help you out. Well, if you have access to Visual Studio 2005's Debug->Exceptions... menu item, you can actually tell Visual Studio to allow you to see those first chance exceptions. If you don't have that, however you can put Environment.FastFail(String) in an exception, and use deductive reasoning and process of elimination to find out where your problem in.

Reference

cgreeno
Debugger.Launch and Debugger.Break can also be helpful with this kind of scnenario.
binarycoder
Is there any difference between this and `Process.GetCurrentProcess().Kill()`?
chaiguy
A: 

It kills the application and even skips try/finally blocks.

PRINCESS FLUFF