当前位置: 首页>>代码示例>>C#>>正文


C# Server.ShutdownAsync方法代码示例

本文整理汇总了C#中Grpc.Core.Server.ShutdownAsync方法的典型用法代码示例。如果您正苦于以下问题:C# Server.ShutdownAsync方法的具体用法?C# Server.ShutdownAsync怎么用?C# Server.ShutdownAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Grpc.Core.Server的用法示例。


在下文中一共展示了Server.ShutdownAsync方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            const int port = 1337;

            var serviceImpl = new PlaygroundServiceImpl(new PersonRepository());
            var server = new Grpc.Core.Server
            {
                Services = { PlaygroundService.BindService(serviceImpl) },
                Ports =
                {
                    new ServerPort("0.0.0.0", port, new SslServerCredentials(
                        new[]
                        {
                            new KeyCertificatePair(
                                File.ReadAllText("certificates\\server.crt"),
                                File.ReadAllText("certificates\\server.key"))
                        }))
                }
            };
            server.Start();

            Console.WriteLine("RPC server listening on port " + port);
            Console.WriteLine("Press any key to stop the server...");
            Console.ReadKey();

            serviceImpl.Shutdown();
            server.ShutdownAsync().Wait();
        }
开发者ID:mleenhardt,项目名称:grpc-playground,代码行数:28,代码来源:Program.cs

示例2: StartAndShutdownServer

 public void StartAndShutdownServer()
 {
     Server server = new Server();
     server.AddListeningPort("localhost", Server.PickUnusedPort);
     server.Start();
     server.ShutdownAsync().Wait();
     GrpcEnvironment.Shutdown();
 }
开发者ID:hmings888,项目名称:grpc,代码行数:8,代码来源:ServerTest.cs

示例3: StartAndShutdownServer

 public void StartAndShutdownServer()
 {
     Server server = new Server
     {
         Ports = { new ServerPort("localhost", ServerPort.PickUnused, ServerCredentials.Insecure) }
     };
     server.Start();
     server.ShutdownAsync().Wait();
 }
开发者ID:larsonmpdx,项目名称:grpc,代码行数:9,代码来源:ServerTest.cs

示例4: StartAndShutdownServer

        public void StartAndShutdownServer()
        {
            GrpcEnvironment.Initialize();

            Server server = new Server();
            server.AddListeningPort("localhost:0");
            server.Start();
            server.ShutdownAsync().Wait();

            GrpcEnvironment.Shutdown();
        }
开发者ID:jwatt,项目名称:kythe,代码行数:11,代码来源:ServerTest.cs

示例5: CannotModifyAfterStarted

        public void CannotModifyAfterStarted()
        {
            Server server = new Server
            {
                Ports = { new ServerPort("localhost", ServerPort.PickUnused, ServerCredentials.Insecure) }
            };
            server.Start();
            Assert.Throws(typeof(InvalidOperationException), () => server.Ports.Add("localhost", 9999, ServerCredentials.Insecure));
            Assert.Throws(typeof(InvalidOperationException), () => server.Services.Add(ServerServiceDefinition.CreateBuilder("serviceName").Build()));

            server.ShutdownAsync().Wait();
        }
开发者ID:larsonmpdx,项目名称:grpc,代码行数:12,代码来源:ServerTest.cs

示例6: PickUnusedPort

        public void PickUnusedPort()
        {
            Server server = new Server
            {
                Ports = { new ServerPort("localhost", ServerPort.PickUnused, ServerCredentials.Insecure) }
            };

            var boundPort = server.Ports.Single();
            Assert.AreEqual(0, boundPort.Port);
            Assert.Greater(boundPort.BoundPort, 0);

            server.Start();
            server.ShutdownAsync().Wait();
        }
开发者ID:larsonmpdx,项目名称:grpc,代码行数:14,代码来源:ServerTest.cs

示例7: Main

        public static void Main(string[] args)
        {
            Server server = new Server
            {
                Services = { Greeter.BindService(new GreeterImpl()) },
                Ports = { new ServerPort("localhost", Port, ServerCredentials.Insecure) }
            };
            server.Start();

            Console.WriteLine("Greeter server listening on port " + Port);
            Console.WriteLine("Press any key to stop the server...");
            Console.ReadKey();

            server.ShutdownAsync().Wait();
        }
开发者ID:xianglinghui,项目名称:grpc,代码行数:15,代码来源:Program.cs

示例8: Main

        public static void Main(string[] args)
        {
            GrpcEnvironment.Initialize();

            Server server = new Server();
            server.AddServiceDefinition(Greeter.BindService(new GreeterImpl()));
            int port = server.AddListeningPort("localhost", 50051);
            server.Start();

            Console.WriteLine("Greeter server listening on port " + port);
            Console.WriteLine("Press any key to stop the server...");
            Console.ReadKey();

            server.ShutdownAsync().Wait();
            GrpcEnvironment.Shutdown();
        }
开发者ID:hongweiwang,项目名称:grpc-common,代码行数:16,代码来源:Program.cs

示例9: Main

        public static void Main(string[] args)
        {
            Server server = new Server
            {
                Services = { Math.BindService(new MathServiceImpl()) },
                Ports = { { Host, Port, ServerCredentials.Insecure } }
            };
            server.Start();

            Console.WriteLine("MathServer listening on port " + Port);

            Console.WriteLine("Press any key to stop the server...");
            Console.ReadKey();

            server.ShutdownAsync().Wait();
        }
开发者ID:radoslav-furnadgiev,项目名称:grpc,代码行数:16,代码来源:MathServer.cs

示例10: MainAsync

        public static async Task MainAsync()
        {
            var server = new Server
            {
                Services = { Greeter.BindService(new GreeterImpl()) },
                Ports = { new ServerPort(Host, Port, ServerCredentials.Insecure) }
            };

            server.Start();

            Console.Out.WriteLine("Greeter server listening on port {0}", Port.ToString());
            Console.Out.WriteLine("Press any key to stop the server...");
            Console.ReadKey();

            await server.ShutdownAsync().ConfigureAwait(false);
        }
开发者ID:madhon,项目名称:grpc_greeter,代码行数:16,代码来源:Program.cs

示例11: Main

        public static void Main(string[] args)
        {
            string host = "0.0.0.0";

            Server server = new Server();
            server.AddServiceDefinition(Math.BindService(new MathServiceImpl()));
            int port = server.AddPort(host, 23456, ServerCredentials.Insecure);
            server.Start();

            Console.WriteLine("MathServer listening on port " + port);

            Console.WriteLine("Press any key to stop the server...");
            Console.ReadKey();

            server.ShutdownAsync().Wait();
            GrpcEnvironment.Shutdown();
        }
开发者ID:rootusr,项目名称:grpc,代码行数:17,代码来源:MathServer.cs

示例12: Main

        static void Main(string[] args)
        {
            var features = RouteGuideUtil.ParseFeatures(RouteGuideUtil.DefaultFeaturesFile);
            GrpcEnvironment.Initialize();

            Server server = new Server();
            server.AddServiceDefinition(RouteGuide.BindService(new RouteGuideImpl(features)));
            int port = server.AddListeningPort("localhost", 50052);
            server.Start();

            Console.WriteLine("RouteGuide server listening on port " + port);
            Console.WriteLine("Press any key to stop the server...");
            Console.ReadKey();

            server.ShutdownAsync().Wait();
            GrpcEnvironment.Shutdown();
        }
开发者ID:hongweiwang,项目名称:grpc-common,代码行数:17,代码来源:Program.cs

示例13: Main

        static void Main(string[] args)
        {
            const int Port = 50052;

            var features = RouteGuideUtil.ParseFeatures(RouteGuideUtil.DefaultFeaturesFile);

            Server server = new Server
            {
                Services = { RouteGuide.BindService(new RouteGuideImpl(features)) },
                Ports = { new ServerPort("localhost", Port, ServerCredentials.Insecure) }
            };
            server.Start();

            Console.WriteLine("RouteGuide server listening on port " + Port);
            Console.WriteLine("Press any key to stop the server...");
            Console.ReadKey();

            server.ShutdownAsync().Wait();
        }
开发者ID:larsonmpdx,项目名称:grpc,代码行数:19,代码来源:Program.cs

示例14: Main

        static void Main(string[] args)
        {
            var gameAdminService = new GameAdminServiceServer(
                new HardcodedAccountRepository(),
                new HardcodedChatMessageRepository());

            const int port = 1337;
            var rpcServer = new Grpc.Core.Server
            {
                Services = { GameAdminService.BindService(gameAdminService) },
                Ports = { new Grpc.Core.ServerPort("localhost", port, ServerCredentials.Insecure) }
            };
            rpcServer.Start();

            Log("GameAdminService server listening on port " + port);
            Log("Press any key to stop the server...");
            Console.ReadKey();

            Log("GameAdminService shutting down");
            rpcServer.ShutdownAsync().Wait();
        }
开发者ID:mleenhardt,项目名称:grpc-demo,代码行数:21,代码来源:Program.cs

示例15: RunAsync

        private async Task RunAsync()
        {
            string host = "0.0.0.0";
            int port = options.DriverPort;

            var tcs = new TaskCompletionSource<object>();
            var workerServiceImpl = new WorkerServiceImpl(() => { Task.Run(() => tcs.SetResult(null)); });
                
            var server = new Server
            {
                Services = { WorkerService.BindService(workerServiceImpl) },
                Ports = { new ServerPort(host, options.DriverPort, ServerCredentials.Insecure )}
            };
            int boundPort = server.Ports.Single().BoundPort;
            Console.WriteLine("Running qps worker server on " + string.Format("{0}:{1}", host, boundPort));
            server.Start();
            await tcs.Task;
            await server.ShutdownAsync();
        }
开发者ID:kriswuollett,项目名称:grpc,代码行数:19,代码来源:QpsWorker.cs


注:本文中的Grpc.Core.Server.ShutdownAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。