,我有以下方法在API控制器的Web API CurrentMessageContext空
[System.Web.Mvc.HttpPost]
public Task<CommandResponse> Send(CommandBase command)
{
var result = new TaskCompletionSource<CommandResponse>();
this.Bus.Send(command).Register<int>(response =>
{
this.Bus.CurrentMessageContext is here null <-------
result.TrySetResult(commandResponse);
});
return result.Task;
}
任何想法,为什么CurrentMessageContext在这里空。我正在关注请求/响应示例。这里唯一的区别是使用Task的异步模式。
感谢, Marinko
你试图在消息上下文中访问什么? – 2013-02-10 20:26:01
发送响应之前设置的标头 – 2013-02-11 21:39:50
如果您不使用任务,会发生什么情况? – 2013-02-11 23:59:25