Re: C# Console app with hidden window and user input



On Sep 6, 3:42 pm, Doug Semler <dougsem...@xxxxxxxxx> wrote:
On Sep 6, 4:25 pm, Dilip <rdil...@xxxxxxxxx> wrote:





On Sep 6, 3:16 pm, Doug Semler <dougsem...@xxxxxxxxx> wrote:

On Sep 6, 4:01 pm, Dilip <rdil...@xxxxxxxxx> wrote:

On Sep 6, 2:19 pm, Jon Skeet [C# MVP] <sk...@xxxxxxxxx> wrote:

Dilip <rdil...@xxxxxxxxx> wrote:
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.

But why not a Windows Forms app that doesn't show any forms? That
sounds like the way forward.

You are not going to believe this but the only reason why this app was
made a service was because the original team did not want it popping
up a console window. In all respects this app was born as a console
app and it does nothing that would bestow the boon of being a service
on it (for example it doesnt and cannot run while there is no user
logged on). So in reality, when the app is under development we
usually use it as a console app which just waits on a console.readline
statement. The reason its waiting on that statement is because after
the user hits enter (or whatever) the app executes clean up code AND
pulls down the UI app (that it launched on start up) at the same
time. On deployment it gets installed as a service and an external
batch script just starts and stops it using the SCM. OnStart launches
the UI app, OnStop executes clean up code and shuts down the UI app.

Now, you see where I am going? This app is *already* a console app.
I don't want to get into the hassle of converting it into a winforms
app. I wanted to retain it as a console app but find a way to shut it
down gracefully while the console window remains hidden.

Move your initialization and cleanup code into the windows application
that is launched. Get rid of the console app, and require the user to
double click the windows application instead.

See.. now you are treating me like a moron :-) I explained the
problem in a way that wouldn't pull in a lot of needless information
that would definitely be irrelevant to you. There is a reason why
that console app exists and its not to simply launch the UI app. it
does a whole bunch of other things that if I start writing down will
obscure the problem completely.

Actually, you have changed the problem domain entirely. However, based
on your current explanation you have the following:

Application A
Initializes something (irrelevant what it is)
Launches App B
Waits for a signal (currently Console.ReadLine)
Brings down application B
Cleans up something (again irrelevant)

Application B
"Complicated" Windows Application that does something.

I have serious issues with this design.

I need to bring this thread to a close but since you took so much time
to type up your opinion I would be insulting you by not responding. I
will keep this short. This is the way this application has been
written and most of your concerns have been handled one way or the
other. I don't know why its written this way and I am pretty sure in
hindsight I myself would embark on thousand different ways of doing
things. Its a little too late in the day to do any major
rearchitecting since the project has been around for 5 years now.

as things stand my task is to get it running on Vista and whether I
like it or not I *have* to stick to that :-)

.



Relevant Pages

  • Re: Windows CE Splash and Shell
    ... for each Launch key windows CE checks signal started ... dependencies before launching the App. ... Windows Embedded Manager ... have a Windows CE image with standard shell working ...
    (microsoft.public.windowsce.embedded)
  • Re: WaitForSingleObject returns immediately
    ... So you'll have the same problem on "regular" Windows CE if the apps you use single-instance themselves. ... There is a different approach to take, though, if you want to know when an app terminates. ... > My application should be able to receive a command line and launch the ...
    (microsoft.public.windowsce.app.development)
  • Re: C# Console app with hidden window and user input
    ... hide its console window when its launched out on the field. ... console window at launch time. ... create a Windows Service or a simple Windows Forms app that happens not ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: WaitForSingleObject returns immediately
    ... Most, but not necessarily all, Windows CE apps will check to see if there is ... the app minimizes when the ... The first time my application tries to launch another application, ... #if!defined WINCE ...
    (microsoft.public.windowsce.app.development)
  • Re: Windows.. its like coming home!
    ... gradual transition, especially in going from OS 9 to OS X. ... They needed something that could compete with Windows, ... mean by the "2 of every app" comment before - Apple took whatever apps ... I've found that because the Dock shows applications rather than windows, ...
    (comp.sys.mac.advocacy)