Exemplo n.º 1
0
        static void Main(string[] args)
        {
            if (args != null && args.Length > 0)
            {
                if (args[0].ToUpper() == "C")
                {
                    //以控制台运行
                    try
                    {
                        IsConsole = true;
                        SyncServer SyncServer = new SyncServer();
                        SyncServer.Debug += SyncServer_Debug;
                        //调试模式
                        if (args.Length > 1 && args[1].ToUpper() == "D")
                        {
                            IsDebug = true;
                        }
                        SyncServer.Start();
                        Console.ReadLine();
                        SyncServer.Stop();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                    return;
                }
            }
            //以Windows服务器运行
            SyncService SyncService = new SyncService();

            ServiceBase[] ServicesToRun;
            ServicesToRun = new ServiceBase[]
            {
                SyncService
            };
            ServiceBase.Run(ServicesToRun);
        }