使用NServiceBus与Asp.Net MVC 2 [英] Using NServiceBus with Asp.Net MVC 2

查看:144
本文介绍了使用NServiceBus与Asp.Net MVC 2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法使用NServiceBus与Asp.Net MVC 2?我想从一个Asp.Net MVC2应用程序发送一个请求消息发送到服务,该服务处理和回复信息与响应消息。有没有办法清楚地做到这一点?

Is there a way to using NServiceBus with Asp.Net MVC 2? I want to send a request message from a Asp.Net MVC2 Application to a Service, which handle the message and reply with a response message. is there a way to do this clearly?

推荐答案

如果您的真正的要做到这一点,方法如下:

If you really want to do this, here's how:

var sync = Bus.Send<SomeMessage>(/*data*/)
    .Register((AsyncCallback)delegate(IAsyncResult ar) {
        var result = ar.AsyncState as CompletionResult;

        // do something with result.Messages
    },
    null
);

sync.AsyncWaitHandle.WaitOne(/*timeout*/);

这篇关于使用NServiceBus与Asp.Net MVC 2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆