-Right, that is why I want to free the handle outside the ConsumerOf<>
impl, but without any way of knowing when an Send() procedure is
completed I can't do that
-The handle is set inside the Beginxxx call in the IAsyncResult
implementation and that handle is later delegated to in its
corresponding Endxxx call, so I am not sure I see how other messages/
consumers would be affected...only the caller thread dealing with the
IAsyncResult should be involved.


On Dec 22, 11:45 pm, "Ayende Rahien" <[email protected]> wrote:
> That is exactly the kind of thing that I would like to avoid doing.
> For one thing, who is going to set the wait handle.
> For another, how do you know which message set this up? If you get
> MessageProcessingCompleted, you might free the handle for a completely
> irrelevant message.
>
> On Tue, Dec 23, 2008 at 8:40 AM, Mike Nichols <[email protected]>wrote:
>
>
>
> > Sure...as you've probably noticed I am newish to asynch concepts :),
> > but here is an BeginSend invocation I am trying to accomplish to use
> > MR's Async actions:
> > public IAsyncResult BeginSend(AsyncCallback asyncCallback, object
> > asyncState, params object[] messages)
> >                {
> >                        var ar = new AsyncResult<TResult>(asyncCallback,
> > messages);
>
> >                        WaitCallback send = state =>
> >                        {
> >                                try
> >                                {
> >                                        var consumer = new
> > RequestConsumer<TResult>(ar);
>
> >                                        using
> > (bus.AddInstanceSubscription(consumer))
> >                                        {
> >                                                bus.Send(messages);
> >                                                //wait on new thread for op
> > to complete inside consumer
>
> >  ar.AsyncWaitHandle.WaitOne();
> >                                        }
> >                                        bus = null;// Allow early GC
> >                                }
> >                                catch (Exception ex)
> >                                {
> >                                        ar.SetAsCompleted(ex, false);
> >                                }
> >                        };
> >                        ThreadPool.QueueUserWorkItem(send, ar);
> >                        return ar;
> >                }
>
> > This works fine if the ConsumerOf<> impl has access to the wait handle
> > being used by the AsyncResult, but that is a constraint I'd rather
> > avoid. So it'd be good to just call :
> > bus.MessageProcessingCompleted+=MyHandlerThatSetsTheHandleSignal
>
> > I am not proposing to burden IServiceBus with a ton of events, but am
> > not sure how to accomplish this...
>
> > On Dec 22, 11:26 pm, "Ayende Rahien" <[email protected]> wrote:
> > > Can you explain exactly what you are trying to do? I am not sure that I
> > > understand.
>
> > > On Tue, Dec 23, 2008 at 8:21 AM, Mike Nichols <[email protected]
> > >wrote:
>
> > > > I want to attach an handle.Set() to fire an 'Consumexxx' is called by
> > > > RSB. Currently, the events aren't exposed by ITransport to do this
> > > > (specifically MessageArrived event).
> > > > My question is, is this a bad idea?
> > > > I'm working on an BeginSend and EndSend asynch wrapper for RSB but I
> > > > don't want all my Consumers to require access to the IAsyncResult
> > > > handle to tell the thread the message is consumed:
>
> > > > public void Consume(MyMessage msg){
> > > >   //do stuff
> > > >   handle.Set()
> > > > };
>
> > > > Really what should be handled is the end of the entire Send()
> > > > lifecycle (maybe MessageProcessingCompleted but it isn't exposed) so
> > > > the thread can be told to resume.
>
> > > > Am I off on this or should some kind of event be exposed for this?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Rhino Tools Dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rhino-tools-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to