I have a small "Console Application" with Output type "Windows application" (Since I don't want a Console-UI). I create a ContextMenu for the system tray and initialize a Timer. After I have done that I want the application to stay alive until someone closes it using the UI. Whats the best / cleanest approach here? Since I have no console I can't use Readline, what seems to be the way to go in any other case.
private static void Main()
{
var trayMenu = new ContextMenu();
trayMenu.MenuItems.Add("Exit", OnExit);
var notifyIcon = new NotifyIcon
{
Text = @"Foo Bar",
ContextMenu = trayMenu,
Visible = true
};
var timer = new Timer {Interval = 20000};
timer.Tick += DoStuff;
timer.Start();
//KEEP SOMEHOW ALIVE
}