本文整理汇总了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);
}
示例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();
}
示例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!");
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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);
}
示例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();
}
示例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;
}
示例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();
}
示例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());
}
示例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();
}
示例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;
}