I have a FATAL error that can occur deep in the code of a single-threaded background console app that was written in C# 4. Is there any advantage or disadvantage to calling Environment.Exit(1) right there, or is it better to percolate an Exception all the way to int main() and call return(1)? The former seems direct and quick, while having an Exception wending its way up the stack trace seems like extra processing if it doesn't give me any advantages.
Technical answers are welcome. I have programmed for 37 years in C, 32 in C++, and 20 in Java, but am just past newby status in C#.
Beartooth BronskyPosted Mar 24, 2017, 2:04 PM
Haha. I should have said I started C 37 years ago, added C++ 5 years later, and added Java in 1997 when it first became commercially stable. I also used 80x86 assembler during the PC DOS years. Before that, I did COBOL, BAL, and RPG II, with a bit of FORTRAN and EDL. It only SEEMS sometimes like I've been doing this for 89 years instead of 42.
I have continued to use C/C++ (an extension of C and a "better" C if you don't want to dance as much on the razor's edge ;) ) and Java regularly, often mixing them on the same projects, with plain old C still my favorite for its ability to go to such a low level and, under DOS, bypass both DOS and BIOS levels for efficiency. I have done a lot of digital video and financial algorithmic trading and datamining work that contains modules that Java is just not flexible enough to handle, so separate services are often done in different languages as needed.
Nilesh ShahPosted Mar 23, 2017, 2:56 PM