Hi,
Thanks for the link but I had come across this before and if I was rude in my 
answer then it was unintentional and I apologise.The main point of my question 
was how to return my domain object to the web layer from the EndPeek event 
handler defined below:
 
 private void ReceiveQ_PeekCompleted(object sender, PeekCompletedEventArgs e) { 
       MessageQueue messageQueue = sender as MessageQueue;        using 
(Message message = messageQueue.EndPeek(e.AsyncResult))        {            if 
(!message.CorrelationId.Equals(_correlationId))            {                
messageQueue.BeginPeek(_timeOut);                return;            }        }  
      using (Message message = 
messageQueue.ReceiveByCorrelationId(_correlationId))       {             //DO 
processing }}
 
I defined a custom event which is raised back to the Ui layer which is outlined 
below:
 
using (Message message = messageQueue.ReceiveByCorrelationId(_correlationId))
{
    try
    {
        XmlDocument doc = new XmlDocument();
        doc.LoadXml((string)message.Body);
        if (MessageProcessed != null)
        {
            _receiveQ.EndPeek(e.AsyncResult);
            MessageProcessed(this, new MSMQEventArguments<XmlDocument>(doc));
        }
    }
    catch (Exception ex)
    {
        log.Error("Dom loading error", ex);
    }
}
 
MessageProcessed is the custom event I have created. I take it this is the best 
way to do this?
I would be curious to know what are the steps involved in making this whole 
process asynchronous?
 
My method call starts out like this:
 
public void CalculateOrder(ShoppingCart cart, OrderCalculatedHandler 
orderCalculatedHanlder)
{
    try
    {
        OrderBuilder orderBuilder = new 
OrderBuilder(OrderBuilder.OrderMessage.CALCULATEORDER);
        MSMQHelper helper = new MSMQHelper();
        helper.MessageProcessed += new 
MSMQMessageProcessedHandler(Helper_MessageProcessed);
        OrderCalculated += new OrderCalculatedHandler(orderCalculatedHanlder);
        helper.RequestAsync(orderBuilder.Build(cart));
    }
    catch (Exception ex)
    {
        log.Error("MSMQHelper.Request", ex);
        throw ex;
    }
}
 
How would I turn this into an async method and do you think it really is worth 
my while going down this route?
 
I’m not asking for the code, just some advise off some people with experience 
of this.
[EMAIL PROTECTED]

> Date: Sun, 6 Aug 2006 14:21:52 -0400> From: [EMAIL PROTECTED]> Subject: Re: 
> [ADVANCED-DOTNET] Asynchronous Design Question> To: 
> [email protected]> > It explains to you the steps required 
> to make a page asynchronous and> many code examples for various scenarios. I 
> think this answer the part> of your email saying "The problem I have is I am 
> struggling with the> whole asynchronous model."> > Sébastien> > On 8/6/06, 
> Paul Cowan <[EMAIL PROTECTED]> wrote:> > How does this answer my [EMAIL 
> PROTECTED]> >> > -- > Sébastien Lorion> Software Architect / Architecte 
> organique> [EMAIL PROTECTED]> > ===================================> This 
> list is hosted by DevelopMentor®  http://www.develop.com> > View archives and 
> manage your subscription(s) at http://discuss.develop.com
===================================
This list is hosted by DevelopMentor®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to