Код: Выделить всё
[ServiceContract]
public interface IFooService
{
[OperationContract]
string GetFoo(int value);
[OperationContract]
Task GetBarAsync();
}
public class FooService : IFooService
{
public string GetFoo(int value)
{
return value.ToString();
}
public Task GetBarAsync()
{
return Task.Run(() =>
{
Task.Delay(6000).Wait();
return "done!";
});
}
}
Код: Выделить всё
class Program
{
public static async Task Main(string[] args)
{
NetNamedPipeBinding binding = new NetNamedPipeBinding();
var proxy = new ChannelFactory(binding, new EndpointAddress("net.pipe://localhost/Test")).CreateChannel();
Console.WriteLine("GetFoo result: " + proxy.GetFoo(1));
var tmp = await proxy.GetBarAsync();
Console.WriteLine("GetBarAsync result: " + tmp);
Console.WriteLine("GetFoo result: " + proxy.GetFoo(2));
Console.ReadLine();
}
}
Может кто-нибудь объяснить, почему? Это тупик? Или канал WCF не поддерживает асинхронные вызовы?
Подробнее здесь: https://stackoverflow.com/questions/785 ... -dead-lock
Мобильная версия