Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C#: Non-Winforms way to exit the application?

Tags:

c#

.net

I know about Application.Exit() but what if I'm not in a windows forms application but in a simple class library, how do I signal for the application to exit?

like image 267
George Mauer Avatar asked Oct 07 '08 00:10

George Mauer


2 Answers

Environment.Exit() -- but why would you ever want to do this from a method in a class library?

like image 90
tvanfosson Avatar answered Oct 05 '22 11:10

tvanfosson


P/Invoke ExitProcess, perhaps. Or if you're really in a hurry, TerminateProcess.

like image 31
Chris Charabaruk Avatar answered Oct 05 '22 11:10

Chris Charabaruk