Имея следующую конфигурацию с использованием refit:
services.AddRefitClient<BackendService_ApiProxy>()
.ConfigureHttpClient(httpClient =>
{
httpClient.Timeout = TimeSpan.FromSeconds(15);
httpClient.BaseAddress = new Uri("http://service1.company.com.au");
}
services.AddRefitClient<BackendService2_ApiProxy>()
.ConfigureHttpClient(httpClient =>
{
httpClient.Timeout = TimeSpan.FromSeconds(15);
httpClient.BaseAddress = new Uri("http://service2.company.com.au");
}
Использование:
var task1 = backendService_ApiProxy.GetCustomerAsync();
var task2 = backendService2_ApiProxy.GetOrderAsync();
await Task.WhenAll(new List<Task> {task1, task2});
Установка библиотеки Nuget Ben.BlockingCode и обнаружение вышеуказанной библиотеки refit имеет код блокировки. Есть идеи почему? я делаю / или использую ремонт неправильно?
[Warning - Ben.Diagnostics.BlockingMonitor] Blocking method has been invoked and blocked, this can lead to threadpool starvation.
at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)\n
at System.Reflection.Assembly.LoadFrom(String assemblyFile)\n at System.Net.Http.HttpClient.SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)\n
at Refit.RequestBuilderImplementation.<>c__DisplayClass14_0`2.<<BuildCancellableTaskFuncForMethod>b__0>d.MoveNext()\n
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)\n
at Refit.RequestBuilderImplementation.<>c__DisplayClass14_0`2.<BuildCancellableTaskFuncForMethod>b__0(HttpClient client, CancellationToken ct, Object[] paramList)\n
at Refit.RequestBuilderImplementation.<>c__DisplayClass19_0`2.<BuildTaskFuncForMethod>b__0(HttpClient client, Object[] paramList)\n
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)\n at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)\n
at System.Delegate.DynamicInvokeImpl(Object[] args)\n
at BackendService.Contract.Proxy.AutoGeneratedIApiService.BackendService.Contract.Proxy.IApiService.GetCustomerAsync(Guid customerId, CancellationToken cancellationToken)