Re: C# Console app with hidden window and user input
- From: "Willy Denoyette [MVP]" <willy.denoyette@xxxxxxxxxx>
- Date: Thu, 6 Sep 2007 21:49:12 +0200
"Dilip" <rdilipk@xxxxxxxxx> wrote in message news:1189104733.485753.116930@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Sep 6, 1:10 pm, Jon Skeet [C# MVP] <sk...@xxxxxxxxx> wrote:Dilip <rdil...@xxxxxxxxx> wrote:
> I have a server based C# console application. This application must
> hide its console window when its launched out on the field. So I
> dutifully P/Invoke'd FindWindow/ShowWindow combination to hide the
> console window at launch time.
> The application (for legacy reasons) hangs around by waiting on an old-
> fashioned Console.ReadLine() statement.
> How can such an application be terminated externally? By externally I
> mean via a batch file or script or some such? Launching is the easy
> part. How does a hidden console window recieve keyboard input so that
> the shut down code can execute?
> Or am I going about this the wrong way?
Why have you made it a console app if you don't want a console? Just
create a Windows Service or a simple Windows Forms app that happens not
to display any forms.
I should've prefaced my question with all of this.
The application *was* a service but strangely it also launches a
complex Winforms based application (now please don't ask me why or how
-- thats just the way it is). Under Vista however Services cannot
interact with the desktop (as they run on Session 0 which is different
from the ones UI apps run) and hence cannot launch another application
that displays UI.
So I am trying to work backwards by converting that application to a
console app but w/the console window hidden.
The problem I am running into happens when I want to shut it down.
Because its now hidden I don't know how to shut it down gracefully.
Given the constraints is there any way to do it from an external
script? It has to be an external batch file or something that
probably has a short cut to it in the Start menu.
I am open to approaches that don't rely on Console.ReadLine().
Maybe I could create an event and wait on it.script once again I could probably do a SetEvent on the event thusFrom a totally different tiny app2 that can be launched from the
opened and get the code to shut down gracefully.
Will that work?
The console application has to be started by a "human being", right?, why not let him start the Windows application instead?
Willy.
.
- References:
- C# Console app with hidden window and user input
- From: Dilip
- Re: C# Console app with hidden window and user input
- From: Jon Skeet [C# MVP]
- Re: C# Console app with hidden window and user input
- From: Dilip
- C# Console app with hidden window and user input
- Prev by Date: Re: High res timer
- Next by Date: Re: C# -> two buttons same code
- Previous by thread: Re: C# Console app with hidden window and user input
- Next by thread: Re: C# Console app with hidden window and user input
- Index(es):
Loading