コード例 #1
0
        /// <summary>
        /// 这是服务主机进程的入口点。
        /// </summary>
        private static void Main()
        {
            try
            {
                // ServiceManifest.XML 文件定义一个或多个服务类型名称。
                // 注册服务会将服务类型名称映射到 .NET 类型。
                // 在 Service Fabric 创建此服务类型的实例时,
                // 会在此主机进程中创建类的实例。

                ThreadPool.SetMinThreads(10000, 500);//线程池 最小

                ServicePointManager.DefaultConnectionLimit = int.MaxValue;
                ServicePointManager.UseNagleAlgorithm      = false;
                ServicePointManager.Expect100Continue      = false;

                LoggingSource.Initialize(ServiceEventSource.Current.Message);

                ServiceRuntime.RegisterServiceAsync("PublicGateType",
                                                    context => new PublicGate(context)).GetAwaiter().GetResult();

                ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, typeof(PublicGate).Name);

                // 防止此主机进程终止,以使服务保持运行。
                Thread.Sleep(Timeout.Infinite);
            }
            catch (Exception e)
            {
                ServiceEventSource.Current.ServiceHostInitializationFailed(e.ToString());
                throw;
            }
        }
        public static void Main(string[] args)
        {
            try
            {
                ThreadPool.SetMinThreads(10000, 500);
                ServicePointManager.DefaultConnectionLimit = int.MaxValue;
                ServicePointManager.UseNagleAlgorithm      = false;
                ServicePointManager.Expect100Continue      = false;

                LoggingSource.Initialize(ServiceEventSource.Current.Message);

                ServiceRuntime.RegisterServiceAsync(
                    "StockServiceType",
                    context =>
                    new StockService(context)).GetAwaiter().GetResult();

                ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, typeof(StockService).Name);

                Thread.Sleep(Timeout.Infinite);
            }
            catch (Exception e)
            {
                ServiceEventSource.Current.ServiceHostInitializationFailed(e.ToString());
                throw;
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: chenhongyi/CKZTGameService
        public static void Main(string[] args)
        {
            try
            {
                // Initializing ILogger   111
                LoggingSource.Initialize(ServiceEventSource.Current.Message);

                ServiceRuntime.RegisterServiceAsync(
                    "StockAggregatorServiceType",
                    context =>
                    new StockAggregatorService(context)).GetAwaiter().GetResult();

                ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, typeof(StockAggregatorService).Name);

                Thread.Sleep(Timeout.Infinite);
            }
            catch (Exception e)
            {
                ServiceEventSource.Current.ServiceHostInitializationFailed(e.ToString());
                throw;
            }
        }
        public static void Main(string[] args)
        {
            try
            {
                ThreadPool.SetMinThreads(10000, 500);
                ServicePointManager.DefaultConnectionLimit = int.MaxValue;
                ServicePointManager.UseNagleAlgorithm      = false;
                ServicePointManager.Expect100Continue      = false;

                LoggingSource.Initialize(ActorEventSource.Current.Message);


                ActorRuntime.RegisterActorAsync <StockTrendPredictionActor>().GetAwaiter().GetResult();
                ActorRuntime.RegisterActorAsync <NotificationActor>().GetAwaiter().GetResult();

                Thread.Sleep(Timeout.Infinite);
            }
            catch (Exception e)
            {
                ActorEventSource.Current.ActorHostInitializationFailed(e.ToString());
                throw;
            }
        }