预编译命令 #if DEBUG

在控制台程序根据预编译命令:

http://www.askapache.com/windows/advanced-batch-scripting.html


namespace
SXGYCarTransfrom.Handle { class Program { static void Main(string[] args) { #if DEBUG RunAsConsole(); #else RunAsServer(); #endif } /// <summary> /// DEBUG 时跑的为控制台程序 /// </summary> private static void RunAsConsole() { AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(TaskStart.CurrentDomain_UnhandledException); var _task = new TaskStart(); while (true) { // 输出日志 Console.ReadLine(); } } /// <summary> /// Release 时启动的为服务 /// </summary> private static void RunAsServer() { ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new TransService() }; ServiceBase.Run(ServicesToRun); } } }

 

posted @ 2016-08-09 18:10  闲莫等  阅读(619)  评论(0编辑  收藏  举报