console as background app...

  • Thread starter Thread starter Jake Yu
  • Start date Start date
J

Jake Yu

hi,

i want to make the console application running at the background but not
as a service by hiding the console window...

can anyone help me on this?

Jake
 
Do it as a windows app that doesnt have a form. As far as i know you can hide
the console as windows provides it. It will have to be a windows app where
you dont show a form in Main but do something else.

Ciaran O'Donnell
 
Thanks for your reply...

There is a way to hide the console window by calling win32 functions,
GetConsoleWindow and ShowWindow. But it still shows the console window
before trying to hide by calling win32 apis.

Anyway, i created new windows app this time and created a thread to do
what i wanted to do at the background before calling Application.Run()
without passing Form to Run method. But when i finished work in the
thread, i don't know how to quit the app. In vc++, usually posting
WM_QUIT windows message terminates itself, but how do you achieve the
same thing in c#?

Jake
 
Hi Jake,

1. Returning from the Main method will stop the process

2. Environment.Exit will stop the process

3. Application.Exit will close all Forms and stop all message loops.
Application.Run will then return control to the caller once the exit is
complete.
 
You should call Application.Exit which will return you to the main methods
after the call to application.run().

Ciaran O'Donnell
 
Back
Top