源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

使用windows控制台调试服务的方法

  • 时间:2021-01-13 14:27 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:使用windows控制台调试服务的方法
将Program类的删除,将里面的静态类Main修改后放入服务类中:
[u]复制代码[/u] 代码如下:
partial class Server1 : ServiceBase     {                public Server1()         {             InitializeComponent();         }         /// <summary>         /// 应用程序的主入口点。         /// </summary>         static void Main(string[] args)         {             Server1 sv = new Server1();             if (args.Length > 0)             {                 sv.OnStart(args);                 char c;                 while ((c = Convert.ToChar(Console.Read())) != 'q')                     if (c == 'g') GC.Collect();                 sv.OnStop();                 Console.ReadLine();             }             else             {                 ServiceBase[] ServicesToRun;                 ServicesToRun = new ServiceBase[]             {                 sv             };                 ServiceBase.Run(ServicesToRun);             }         }         protected override void OnStart(string[] args)         {         }         protected override void OnStop()         {         }     }
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部