class Program static void Main string args if Environment UserInteract

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
class Program
{
static void Main(string[] args)
{
if (Environment.UserInteractive) //running as console app
{
new CommandLine(args);
}
else //running as service
{
using (var service = new WindowsService())
{
ServiceBase.Run(service);
}
}
}
}