473,402 Members | 2,064 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

gracefully end console app

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
7 8391
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: KB | last post by:
Hi, I want to write a Python script that controls and automates a Windows GUI computation program. My problem is that I do not know how to quit the Windows GUI program gracefully with a...
2
by: Gary | last post by:
Hi, there, I have an application running on remote machine, and would like to close it gracefully. Like a human go to there, push the stop button, and close it after several seconds. How to...
4
by: William F. Robertson, Jr. | last post by:
One of my developers came to me with this question and I don't have an answer for them. The only suggestion I had for them was to change the return to a output parameter and put a try catch around...
6
by: - Steve - | last post by:
I'm using Forms Based Authentication. I've written my code so that when a user does something but has timed out, it gracefully logs them out and asks them to log back on. I do this with . . ...
6
by: Mark | last post by:
Hello, I'm trying to handle HttpRequestValidationException. If a hacker enters certain values into a textbox, like "<script>", it will trigger this error. I understand why .Net has this, but I...
6
by: Tim Chase | last post by:
While working on a Jumble-esque program, I was trying to get a string into a character array. Unfortunately, it seems to choke on the following import random s = "abcefg" random.shuffle(s) ...
10
by: Philip Pemberton | last post by:
Hi, I'm currently playing around with a little spam filter for my Linksys NSLU2 (I would have used Spamassassin but that's slow even on my 2GHz Athlon64 - on a 266MHz XScale it's likely to be...
5
by: Jon Davis | last post by:
Is there such a thing as a Windows standard for killing a console app that is monitored by a System.Diagnostics.Process object? I'm hosting several C# console apps in a C# Windows service and...
4
!NoItAll
by: !NoItAll | last post by:
I have a program that needs to access the files that are open by another program on the computer. When my application comes up I can easily see if the other application is running with the .net...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.