首页 > 其他 > 详细

预编译命令 #if DEBUG

时间:2016-08-09 18:42:11      阅读:197      评论:0      收藏:0      [点我收藏+]

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

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);
        }
    }
}

 

预编译命令 #if DEBUG

原文:http://www.cnblogs.com/yitong/p/5754214.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!