服务总线中继是否支持异步 wcf 操作?
我得到服务器未能使用以下代码返回有意义的响应。如果我将时间跨度更改为 30 秒,但它工作正常。
按照本教程开始 http://azure.microsoft.com/en-us/documentation/articles/service-bus-dotnet-how-to-use-relay
客户端代码:
var task = Task<string>.Factory.FromAsync(channel.BeginDoEcho, channel.EndDoEcho, input, null);
Console.WriteLine("Server echoed: {0}", task.Result );
服务器代码:
public IAsyncResult BeginDoEcho(string text, AsyncCallback callback, object state)
{
var task = Task<string>.Factory.StartNew(x =>
{
Thread.Sleep(TimeSpan.FromMinutes(5));
return text;
}, state);
return task.ContinueWith(result => callback(task));
}
public string EndDoEcho(IAsyncResult result)
{
return ((Task<string>) result).Result;
}