How to exit a console application?

  • Thread starter Thread starter Boo Khan Ming
  • Start date Start date
B

Boo Khan Ming

Hello,

I am using .NET Compact Framework with a console application. How do I
terminate the program explicitly? I have came to Environment.Exit but later
found out that it isn't available in CF subset.

I have tried Process.GetCurrentProcess.Kill, and one source says that I
should reference to System.Diagnostic, but still doesn't work, saying that
"The type or namespace name 'Process' could not be found...". (When typing
"Process.", there is no member list appeared)

Is there any other way, for my case?

Thanks!

Khan Ming
 
I don't know about CF, but a normal console app you just let the main method
exit, or use a return statement.
 
You do need to import the System.Diagnostics namespace. The Process
class allows you to get the current process details. Create an instance
and it is quite simple.

with regards,


J.V.Ravichandran
- http://www.geocities.com/
jvravichandran
- http://www.411asp.net/func/search?
qry=Ravichandran+J.V.&cob=aspnetpro
- http://www.southasianoutlook.com
- http://www.MSDNAA.Net
- http://www.csharphelp.com
- http://www.poetry.com/Publications/
display.asp?ID=P3966388&BN=999&PN=2
- Or, just search on "J.V.Ravichandran"
at http://www.Google.com
 
Boo Khan Ming said:
I am using .NET Compact Framework with a console application. How do I
terminate the program explicitly? I have came to Environment.Exit but later
found out that it isn't available in CF subset.

I have tried Process.GetCurrentProcess.Kill, and one source says that I
should reference to System.Diagnostic, but still doesn't work, saying that
"The type or namespace name 'Process' could not be found...". (When typing
"Process.", there is no member list appeared)

Is there any other way, for my case?

Yup - use the OpenNETCF.Diagnostics.Process class, from the OpenNETCF
library, which you can download from http://www.opennetcf.org
 
Back
Top