标签:
在控制台程序根据预编译命令:
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); } } }
标签:
原文地址:http://www.cnblogs.com/yitong/p/5754214.html