How to exit a console application?

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
 
P

Peter Rilling

I don't know about CF, but a normal console app you just let the main method
exit, or use a return statement.
 
R

Ravichandran J.V.

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
 
J

Jon Skeet [C# MVP]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top