码迷,mamicode.com
首页 > 其他好文 > 详细

Console

时间:2017-10-30 14:29:47      阅读:176      评论:0      收藏:0      [点我收藏+]

标签:else   read   应用   编译   line   roc   运行   用户   div   

控制台应用程序

启动选项->命令行参数" 指定为任意字符串,如: "/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

标签:else   read   应用   编译   line   roc   运行   用户   div   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!