Beispiel #1
0
 private void CreateSyncServer()
 {
     try
     {
         mSyncServer        = new SyncServer();
         mSyncServer.Debug += SyncServer_Debug;
         mSyncServer.Start();
     }
     catch (Exception ex)
     {
         WriteLog(LogMode.Error, string.Format("CreateSyncServer fail.\t{0}", ex.Message));
     }
 }
Beispiel #2
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);
        }