C # Prevent console application launch as a Windows application from output?

I have a console application, to build as a Windows application, to run as a background process (I call it App 1).
When I launch another application, I send a message to App 1and then processes the message.
I want to prevent App 1ultil from exiting. I press a hot key.

Can you help me how to prevent App 1from automatic exit ? Thank you very much!

+5
source share
3 answers

, , .

:

[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]

public static extern bool RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, int vk);

: http://msdn.microsoft.com/en-us/library/ms646309(v=vs.85).aspx

+3
    static void Main(string[] args)
    {
        // do something here...

        string answer = Console.ReadLine();
        while (answer != "Exit")
        {
            answer = Console.ReadLine();
        }
    }
0
source

All Articles