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


C# Channel.ShutdownAsync方法代码示例

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


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

示例1: ConnectAsync

        public static async Task<WalletClient> ConnectAsync(string networkAddress, string rootCertificate)
        {
            if (networkAddress == null)
                throw new ArgumentNullException(nameof(networkAddress));
            if (rootCertificate == null)
                throw new ArgumentNullException(nameof(rootCertificate));

            var channel = new Channel(networkAddress, new SslCredentials(rootCertificate));
            var deadline = DateTime.UtcNow.AddSeconds(3);
            try
            {
                await channel.ConnectAsync(deadline);
            }
            catch (TaskCanceledException)
            {
                await channel.ShutdownAsync();
                throw new ConnectTimeoutException();
            }

            // Ensure the server is running a compatible version.
            var versionClient = new VersionService.VersionServiceClient(channel);
            var response = await versionClient.VersionAsync(new VersionRequest(), deadline: deadline);
            var serverVersion = new SemanticVersion(response.Major, response.Minor, response.Patch);
            SemanticVersion.AssertCompatible(RequiredRpcServerVersion, serverVersion);

            return new WalletClient(channel);
        }
开发者ID:decred,项目名称:Paymetheus,代码行数:27,代码来源:WalletClient.cs

示例2: Main

        private const string ProjectName = "apiarydotnetclienttesting"; // this is actually gRPC, but I had that project handy

        #endregion Fields

        #region Methods

        static void Main(string[] args)
        {
            // Prerequisites
            // 1. create a new cloud project with your google account
            // 2. enable cloud datastore API on that project
            // 3. 'gcloud auth login' to store your google credential in a well known location (from where GoogleCredential.GetApplicationDefaultAsync() can pick it up).

            var credentials = Task.Run(() => GoogleCredential.GetApplicationDefaultAsync()).Result;

            Channel channel = new Channel("datastore.googleapis.com", credentials.ToChannelCredentials());

            var datastoreClient = new Google.Datastore.V1Beta3.Datastore.DatastoreClient(channel);

            var result = datastoreClient.RunQuery(new RunQueryRequest
            {
                ProjectId = ProjectName,
                GqlQuery = new GqlQuery {
                    QueryString = "SELECT * FROM Foo"
                }
            });

            Console.WriteLine(result);

            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();

            channel.ShutdownAsync();
        }
开发者ID:jtattermusch,项目名称:grpc-samples-unofficial,代码行数:34,代码来源:Program.cs

示例3: Main

 public static void Main(string[] args)
 {
     // This code doesn't do much but makes sure the native extension is loaded
     // which is what we are testing here.
     Channel c = new Channel("127.0.0.1:1000", ChannelCredentials.Insecure);
     c.ShutdownAsync().Wait();
     Console.WriteLine("Success!");
 }
开发者ID:kriswuollett,项目名称:grpc,代码行数:8,代码来源:Program.cs

示例4: Main

 static void Main(string[] args)
 {
     var channel = new Channel("127.0.0.1:9007", ChannelCredentials.Insecure);
     var client = new gRPC.gRPCClient(channel);
     var replay = client.SayHello(new HelloRequest { Name = "shoy" });
     Console.WriteLine(replay.Message);
     channel.ShutdownAsync().Wait();
     Console.ReadKey();
 }
开发者ID:shoy160,项目名称:Shoy.Common,代码行数:9,代码来源:Program.cs

示例5: Main

        public static void Main(string[] args)
        {
            Channel channel = new Channel("127.0.0.1:50051", Credentials.Insecure);

            var client = Greeter.NewClient(channel);
            String user = "you";

            var reply = client.SayHello(new HelloRequest { Name = user });
            Console.WriteLine("Greeting: " + reply.Message);

            channel.ShutdownAsync().Wait();
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }
开发者ID:larsonmpdx,项目名称:grpc,代码行数:14,代码来源:Program.cs

示例6: MainAsync

        public static async Task MainAsync()
        {
            var channel = new Channel("127.0.0.1:50051", ChannelCredentials.Insecure);

            var client = new Greeter.GreeterClient(channel);

            var user = Environment.UserName;

            var reply = client.SayHello(new HelloRequest { Name = user });
            Console.WriteLine("Greeting: {0}", reply.Message);

            await channel.ShutdownAsync().ConfigureAwait(false);

            Console.ReadLine();
        }
开发者ID:madhon,项目名称:grpc_greeter,代码行数:15,代码来源:Program.cs

示例7: Main

        public static void Main(string[] args)
        {
            var channel = new Channel("127.0.0.1", 23456, ChannelCredentials.Insecure);
            Math.IMathClient client = new Math.MathClient(channel);
            MathExamples.DivExample(client);

            MathExamples.DivAsyncExample(client).Wait();

            MathExamples.FibExample(client).Wait();

            MathExamples.SumExample(client).Wait();

            MathExamples.DivManyExample(client).Wait();

            MathExamples.DependendRequestsExample(client).Wait();

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

示例8: Main

        static void Main(string[] args)
        {
            var rpcChannel = new Channel("localhost:1337", ChannelCredentials.Insecure);
            var rpcClient = new GameAdminServiceClient(GameAdminService.NewClient(rpcChannel));

            rpcChannel.ConnectAsync().Wait();
            Log($"GameAdminServiceClient connected to {rpcChannel.ResolvedTarget}, channel state = {rpcChannel.State}");

            rpcClient.GetAccountAsync(1234).Wait();
            rpcClient.GetChatHistoryAsync(Enumerable.Range(1, 2), CancellationToken.None).Wait();
            rpcClient.ListenChatAsync(1234).Wait();
            rpcClient.ChatAsync().Wait();

            Log($"GameAdminServiceClient disconnecting from {rpcChannel.ResolvedTarget}, channel state = {rpcChannel.State}", true);
            rpcChannel.ShutdownAsync().Wait();

            Console.WriteLine("Press any key to stop the client...");
            Console.ReadKey();
        }
开发者ID:mleenhardt,项目名称:grpc-demo,代码行数:19,代码来源:Program.cs

示例9: ConnectAsync

        public static async Task<WalletClient> ConnectAsync(string networkAddress)
        {
            if (networkAddress == null)
                throw new ArgumentNullException(nameof(networkAddress));

            var rootCertificate = await TransportSecurity.ReadCertificate();
            var channel = new Channel(networkAddress, new SslCredentials(rootCertificate));
            var deadline = DateTime.UtcNow.AddSeconds(1);
            try
            {
                await channel.ConnectAsync(deadline);
            }
            catch (TaskCanceledException)
            {
                await channel.ShutdownAsync();
                throw new ConnectTimeoutException();
            }
            return new WalletClient(channel);
        }
开发者ID:tuxcanfly,项目名称:Paymetheus,代码行数:19,代码来源:WalletClient.cs

示例10: Main

        static void Main(string[] args)
        {
            var channel = new Channel("localhost", 1337, new SslCredentials(File.ReadAllText("certificates\\ca.crt")));
            var client = new ServiceClient(PlaygroundService.NewClient(channel));

            var listenTask = client.ListenForNewPeopleAsync();

            client.CreatePersonAsync(new List<Person>
            {
                new Person { Id = 1, Name = "John Doe" },
                new Person { Id = 2, Name = "Lisa Simpson" },
                new Person { Id = 3, Name = "Michael Jackson" },
                new Person { Id = 4, Name = "Mike Bully" },
                new Person { Id = 5, Name = "Mark Commet" },
                new Person { Id = 6, Name = "Alfred Punstar" },
            }).Wait();

            var person = client.GetPersonByIdAsync(5).Result;

            var personList = client.GetPersonListAsync().Result;

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

示例11: updateStatus

        private static void updateStatus()
        {

            string addr = String.Format("{0}:50051", ipAddr);
            Channel channel = new Channel(addr, ChannelCredentials.Insecure);

            McServer.McServerClient client = new McServer.McServerClient(channel);

            Empty statusReq = new Empty();
            BrewStatusReply rep = client.GetStatus(statusReq);
            channel.ShutdownAsync().Wait();

            status.RemainingMashStepList.Clear();

            foreach (MashProfileStep statusMp in rep.RemainingMashSteps)
            {
                var mps = new GFCalc.Domain.MashProfileStep();
                mps.Temperature = statusMp.Temperature;
                mps.StepTime = statusMp.StepTime;

                status.RemainingMashStepList.Add(mps);
            }

            var ol = status.RemainingMashStepList.OrderBy(x => x.Temperature).ToList();
            status.RemainingMashStepList.Clear();

            foreach (GFCalc.Domain.MashProfileStep ms in ol)
            {
                status.RemainingMashStepList.Add(ms);
            }

            status.Temperature = (int)(Math.Round(rep.MashTemperature));
            status.RemainingBoilTime = rep.RemainingBoilTime;
            status.State = rep.CurrentBrewStep;
            status.Progress = rep.Progress;
        }
开发者ID:rmcarlsson,项目名称:wbc,代码行数:36,代码来源:GrainbrainNetDiscovery.cs

示例12: Run

        private async Task Run()
        {
            Credentials credentials = null;
            if (options.useTls)
            {
                credentials = TestCredentials.CreateTestClientCredentials(options.useTestCa);
            }

            List<ChannelOption> channelOptions = null;
            if (!string.IsNullOrEmpty(options.serverHostOverride))
            {
                channelOptions = new List<ChannelOption>
                {
                    new ChannelOption(ChannelOptions.SslTargetNameOverride, options.serverHostOverride)
                };
            }

            var channel = new Channel(options.serverHost, options.serverPort.Value, credentials, channelOptions);
            TestService.TestServiceClient client = new TestService.TestServiceClient(channel);
            await RunTestCaseAsync(options.testCase, client);
            channel.ShutdownAsync().Wait();
        }
开发者ID:radoslav-furnadgiev,项目名称:grpc,代码行数:22,代码来源:InteropClient.cs

示例13: Shutdown_AllowedOnlyOnce

 public void Shutdown_AllowedOnlyOnce()
 {
     var channel = new Channel("localhost", ChannelCredentials.Insecure);
     channel.ShutdownAsync().Wait();
     Assert.Throws(typeof(InvalidOperationException), () => channel.ShutdownAsync().GetAwaiter().GetResult());
 }
开发者ID:nkibler,项目名称:grpc,代码行数:6,代码来源:ChannelTest.cs

示例14: ResolvedTarget

 public void ResolvedTarget()
 {
     var channel = new Channel("127.0.0.1", ChannelCredentials.Insecure);
     Assert.IsTrue(channel.ResolvedTarget.Contains("127.0.0.1"));
     channel.ShutdownAsync().Wait();
 }
开发者ID:nkibler,项目名称:grpc,代码行数:6,代码来源:ChannelTest.cs

示例15: ShutdownFinishesWaitForStateChangedAsync

 public async Task ShutdownFinishesWaitForStateChangedAsync()
 {
     var channel = new Channel("localhost", ChannelCredentials.Insecure);
     var stateChangedTask = channel.WaitForStateChangedAsync(ChannelState.Idle);
     var shutdownTask = channel.ShutdownAsync();
     await stateChangedTask;
     await shutdownTask;
 }
开发者ID:ConfusedReality,项目名称:pkg_network_grpc,代码行数:8,代码来源:ChannelTest.cs


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