相关疑难解决方法(0)

Task <int>如何成为一个int?

我们有这个方法:

async Task<int> AccessTheWebAsync()
{ 
    HttpClient client = new HttpClient();

   Task<string> getStringTask = client.GetStringAsync("http://msdn.microsoft.com");

   // You can do work here that doesn't rely on the string from GetStringAsync.
   DoIndependentWork();

   string urlContents = await getStringTask;
   //The thing is that this returns an int to a method that has a return type of Task<int>
   return urlContents.Length;
}
Run Code Online (Sandbox Code Playgroud)

之间是否隐式转换发生Task<int>int?如果没有,那么发生了什么?它是如何实现的?

.net c# asynchronous c#-5.0 .net-4.5

101
推荐指数
2
解决办法
9万
查看次数

.NET Core WCF 连接服务中是否有同步方法?

我的 .NET Core 项目只为 WCF 服务生成异步方法。有没有办法像在常规 .NET 项目中一样使用同步方法?

在常规的.NET有两个同步和异步方法,如: WcfClient.MethodNameWcfClient.MethodNameAsync

在 .NET Core 中只有 WcfClient.MethodNameAsync

这个问题对我帮助: How to call asynchronous method from synchronous method in C#?

但是这个解决方案会导致其他问题。任何想法如何生成同步方法/函数?

c# wcf .net-core

5
推荐指数
1
解决办法
5657
查看次数

标签 统计

c# ×2

.net ×1

.net-4.5 ×1

.net-core ×1

asynchronous ×1

c#-5.0 ×1

wcf ×1