首页 > 其他 > 详细

Console

时间:2017-10-30 13:53:29      阅读:207      评论:0      收藏:0      [点我收藏+]

控制台应用程序

启动选项->命令行参数" 指定为任意字符串,如: "/cxxx"

 

static void Main(string[] args )
{
    Service1 x = new Service1();
    if (args.Length > 0)
    {
        Console.WriteLine("Console");
        x.OnStart(null);
        Console.ReadLine();
    }
    else
    {
        System.ServiceProcess.ServiceBase[] ServicesToRun;
        // 同一进程中可以运行多个用户服务。若要将
        //另一个服务添加到此进程,请更改下行
        // 以创建另一个服务对象。例如,
        //
        //   ServicesToRun = New System.ServiceProcess.ServiceBase[] {new Service1(), new MySecondUserService()};
        //
        ServicesToRun = new System.ServiceProcess.ServiceBase[] { x};
        System.ServiceProcess.ServiceBase.Run(ServicesToRun);
    }
}

 

  命令行编译:
csc service1.cs

cmd 命令行状态 service1.exe /xxx

EditPlus

 

Console

原文:http://www.cnblogs.com/xiangxiong/p/7753748.html

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