Ways of stopping a C# application in case of an error: System.Environment.FailFast
Posted: (EET/GMT+2)
Sometimes, you might notice a situation in your (desktop) .NET application where continuing execution simply isn't an option, and you must shut down the process quickly.
Now, there are many ways to do this, and of my favorites in the Win32 API world is the TerminateProcess function. However, you have something similar in C# and .NET applications, too: System.Environment.FailFast.
This function is one of those functions where you might start thinking, that "did such a function even exists on the .NET Framework?" But it sure does, and it might get very handy at times.
So, don't overlook this function whenever you need fail fast.