Ah... So in my scenario Bus.Send() is sending the message to a new
instance of Pong. When Pong replies, it's sent to a new instance of
Ping, etc... None of these instances are ever displayed to the user.

It makes sense with Publish/Notify/Send that new instances would be
created. This raises a few questions.

How does Reply work or what is it's purpose?
Is it replying to the the same instance of the object that sent/
published/notified, or is just replying to the end point, the actual
instance handling the reply is different than the one who sent it?
How is Reply different than Send()?
(the previous 3 questions, are probably just the same question asked 3
different ways :) )

The more I experiment with messaging the more it appears messaging
doesn't seem to be a good fit for UI. Rather it's a backend framework/
function. If this is true then it seems you would need an additional
layer between the GUI and messaging to handle the response/
subscription of the results of processing messages.


On Jun 5, 11:59 am, Ayende Rahien <[email protected]> wrote:
> RSB will force components to be transient
>
> On Fri, Jun 5, 2009 at 11:51 AM, Jason Meckley <[email protected]>wrote:
>
>
>
> > 1st I spiked my own console app with simple console.writeline
> > messages. this worked, so long as i blocked the instance subscription
> > with a ManualResetEvent. didn't care for that too much as i'm blocking
> > a thread (no performance gain) and the concept of messaging and a
> > console was already provided with the source.
>
> > now i'm moving on to a simple winforms app. messaging seems to make
> > more sense here because the UI could consume messages and update the
> > interface automatically for the user.
>
> > here is my setup.
> > 1 form, with 2 user controls (Ping and Pong)
> > Ping consumes SentToPing messages and Pong consumes SentToPong
> > messages.
> > When form 1 is shown it tells Ping to send a message to pong
> > Pong consumes the message, changes the background color (red, green),
> > and replies
> > Ping consumes the message, changes the background color (orange, blue)
> > and replies
> > This continues for 10 iterations, then replies stop.
>
> > all is working except:
> > the background color does not change.
> > no exceptions are thrown.
> > I can step through all the code without error.
>
> > having zero experience with win form development am I missing
> > something?
> > code below.
>
> > public partial class Main : Form
> > {
> >        private readonly Ping Ping;
> >        private readonly Pong Pong;
>
> >        public Main(Ping ping, Pong pong)
> >        {
> >                Ping = ping;
> >                Pong = pong;
> >                InitializeComponent();
> >                Shown += MainShown;
> >        }
>
> >        private void MainShown(object sender, EventArgs e)
> >        {
> >                Controls.Add(Ping);
> >                Controls.Add(Pong);
>
> >                Ping.Top = 10;
> >                Pong.Top = Ping.Height + 20;
>
> >                Ping.SendAMessageToPong();
>
> >                Shown -= MainShown;
> >        }
> > }
> > public partial class Ping :
> >        UserControl,
> >        ConsumerOf<SendToPing>
> > {
> >        private readonly IServiceBus Bus;
>
> >        public Ping(IServiceBus bus)
> >        {
> >                Bus = bus;
> >                InitializeComponent();
> >        }
>
> >        public void Consume(SendToPing message)
> >        {
> >                var number = message.Number;
> >                BackColor = number%2 == 0 ? Color.Orange : Color.Blue;
>
> >                Thread.Sleep(500);
> >                Bus.Reply(new SendToPong {Number = number + 1});
> >        }
>
> >        public void SendAMessageToPong()
> >        {
> >                Bus.Send(new SendToPong {Number = 1});
> >        }
> > }
>
> > public partial class Pong :
> >        UserControl,
> >        ConsumerOf<SendToPong>
> > {
> >        private readonly IServiceBus Bus;
>
> >        public Pong(IServiceBus bus)
> >        {
> >                Bus = bus;
> >                InitializeComponent();
> >        }
>
> >        public void Consume(SendToPong message)
> >        {
> >                var number = message.Number;
> >                if (number > 10) return;
>
> >                BackColor = number % 2 == 0 ? Color.Red : Color.Green;
>
> >                Thread.Sleep(500);
> >                Bus.Reply(new SendToPing {Number = number + 1});
> >        }
> > }
>
> > public class StartableForm : IStartable
> > {
> >        private readonly Main Form;
>
> >        public StartableForm(Main form)
> >        {
> >                Form = form;
> >        }
>
> >        public void Start()
> >        {
> >                Application.Run(Form);
> >        }
>
> >        public void Stop()
> >        {
> >        }
> > }
>
> > public class StartableServiceBus : IStartable
> > {
> >        private readonly IStartableServiceBus Bus;
>
> >        public StartableServiceBus(IStartableServiceBus bus)
> >        {
> >                Bus = bus;
> >        }
>
> >        public void Start()
> >        {
> >                Bus.Start();
> >        }
>
> >        public void Stop()
> >        {
> >                Bus.Dispose();
> >        }
> > }
--~--~---------~--~----~------------~-------~--~----~
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