By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,426 Members | 1,721 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,426 IT Pros & Developers. It's quick & easy.

gracefully end console app

P: n/a
Hi,
I have a console app that I want to stop gracefully by another program. The
console app already has code to intercept control-c and logoff and so on.
But how do I send a control-c to that console app from another program? The
console application is started with a Process class.

Thanks
Frank
Dec 27 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Frank,

Why not expose a remoting endpoint which would have a method which will
call Exit on the Environment class?

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Frank" <fr***@frank.com> wrote in message
news:do**********@news6.zwoll1.ov.home.nl...
Hi,
I have a console app that I want to stop gracefully by another program.
The console app already has code to intercept control-c and logoff and so
on. But how do I send a control-c to that console app from another
program? The console application is started with a Process class.

Thanks
Frank

Dec 27 '05 #2

P: n/a
Hi,
The Console app can expose several ways to communicate with it , like :
1- TCP port
2- Named piped
3- Remoting

Any of these can be used to send a "terminate" signal , then you can call
Environment.Exit or Process.Kill to force it to terminate, or do as needed
to gracefully terminate it.

In case you do not have access to modify the app you could use
Process.StandardInput to send a ctrl+c to the app
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Frank" <fr***@frank.com> wrote in message
news:do**********@news6.zwoll1.ov.home.nl...
Hi,
I have a console app that I want to stop gracefully by another program.
The console app already has code to intercept control-c and logoff and so
on. But how do I send a control-c to that console app from another
program? The console application is started with a Process class.

Thanks
Frank

Dec 27 '05 #3

P: n/a
Sending ctrl+c to standardinput does not seem to work. I don't know why not.
thanks
Frank

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>
schreef in bericht news:O9****************@tk2msftngp13.phx.gbl...
Hi,
The Console app can expose several ways to communicate with it , like :
1- TCP port
2- Named piped
3- Remoting

Any of these can be used to send a "terminate" signal , then you can call
Environment.Exit or Process.Kill to force it to terminate, or do as
needed to gracefully terminate it.

In case you do not have access to modify the app you could use
Process.StandardInput to send a ctrl+c to the app
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Frank" <fr***@frank.com> wrote in message
news:do**********@news6.zwoll1.ov.home.nl...
Hi,
I have a console app that I want to stop gracefully by another program.
The console app already has code to intercept control-c and logoff and so
on. But how do I send a control-c to that console app from another
program? The console application is started with a Process class.

Thanks
Frank


Dec 27 '05 #4

P: n/a
Yes, thats on my list
Thanks
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> schreef
in bericht news:e%****************@TK2MSFTNGP11.phx.gbl...
Frank,

Why not expose a remoting endpoint which would have a method which will
call Exit on the Environment class?

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Frank" <fr***@frank.com> wrote in message
news:do**********@news6.zwoll1.ov.home.nl...
Hi,
I have a console app that I want to stop gracefully by another program.
The console app already has code to intercept control-c and logoff and so
on. But how do I send a control-c to that console app from another
program? The console application is started with a Process class.

Thanks
Frank


Dec 27 '05 #5

P: n/a
Hi,

Does it works if you send any other character?

maybe you are not sending the correct sequence.

what about the other options I presented you with?
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Frank" <fr***@frank.com> wrote in message
news:do**********@news4.zwoll1.ov.home.nl...
Sending ctrl+c to standardinput does not seem to work. I don't know why
not.
thanks
Frank

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>
schreef in bericht news:O9****************@tk2msftngp13.phx.gbl...
Hi,
The Console app can expose several ways to communicate with it , like :
1- TCP port
2- Named piped
3- Remoting

Any of these can be used to send a "terminate" signal , then you can call
Environment.Exit or Process.Kill to force it to terminate, or do as
needed to gracefully terminate it.

In case you do not have access to modify the app you could use
Process.StandardInput to send a ctrl+c to the app
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Frank" <fr***@frank.com> wrote in message
news:do**********@news6.zwoll1.ov.home.nl...
Hi,
I have a console app that I want to stop gracefully by another program.
The console app already has code to intercept control-c and logoff and
so on. But how do I send a control-c to that console app from another
program? The console application is started with a Process class.

Thanks
Frank



Dec 27 '05 #6

P: n/a
Hello,
I am sending a hex 3.
The console app does not have a read in it.
Don't need to, if I do a ctrl-c or close the window with the X in the
topright corner it stops gracefully.
Regards
Frank
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>
schreef in bericht news:eA**************@TK2MSFTNGP14.phx.gbl...
Hi,

Does it works if you send any other character?

maybe you are not sending the correct sequence.

what about the other options I presented you with?
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Frank" <fr***@frank.com> wrote in message
news:do**********@news4.zwoll1.ov.home.nl...
Sending ctrl+c to standardinput does not seem to work. I don't know why
not.
thanks
Frank

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>
schreef in bericht news:O9****************@tk2msftngp13.phx.gbl...
Hi,
The Console app can expose several ways to communicate with it , like :
1- TCP port
2- Named piped
3- Remoting

Any of these can be used to send a "terminate" signal , then you can
call Environment.Exit or Process.Kill to force it to terminate, or do
as needed to gracefully terminate it.

In case you do not have access to modify the app you could use
Process.StandardInput to send a ctrl+c to the app
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Frank" <fr***@frank.com> wrote in message
news:do**********@news6.zwoll1.ov.home.nl...
Hi,
I have a console app that I want to stop gracefully by another program.
The console app already has code to intercept control-c and logoff and
so on. But how do I send a control-c to that console app from another
program? The console application is started with a Process class.

Thanks
Frank



Dec 27 '05 #7

P: n/a
Hi,

Well, what about a Process.Kill ?

Not very gracefully, but ... :)

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Frank" <fr***@frank.com> wrote in message
news:do**********@news2.zwoll1.ov.home.nl...
Hello,
I am sending a hex 3.
The console app does not have a read in it.
Don't need to, if I do a ctrl-c or close the window with the X in the
topright corner it stops gracefully.
Regards
Frank
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>
schreef in bericht news:eA**************@TK2MSFTNGP14.phx.gbl...
Hi,

Does it works if you send any other character?

maybe you are not sending the correct sequence.

what about the other options I presented you with?
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Frank" <fr***@frank.com> wrote in message
news:do**********@news4.zwoll1.ov.home.nl...
Sending ctrl+c to standardinput does not seem to work. I don't know why
not.
thanks
Frank

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>
schreef in bericht news:O9****************@tk2msftngp13.phx.gbl...
Hi,
The Console app can expose several ways to communicate with it , like :
1- TCP port
2- Named piped
3- Remoting

Any of these can be used to send a "terminate" signal , then you can
call Environment.Exit or Process.Kill to force it to terminate, or do
as needed to gracefully terminate it.

In case you do not have access to modify the app you could use
Process.StandardInput to send a ctrl+c to the app
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Frank" <fr***@frank.com> wrote in message
news:do**********@news6.zwoll1.ov.home.nl...
> Hi,
> I have a console app that I want to stop gracefully by another
> program. The console app already has code to intercept control-c and
> logoff and so on. But how do I send a control-c to that console app
> from another program? The console application is started with a
> Process class.
>
> Thanks
> Frank
>



Dec 27 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.