tags:

views:

278

answers:

1

I'm studying the .NET Remoting and I see an example on: http://www.mctainsh.com/Articles/Csharp/RemoteCallback.aspx#A%5Fsimple%5Fexample ,all works good. Now my problem is if I try to start another client, server don't callback to all clients connected but only to last one. How can I send callback to all clients?

A: 

Try to change this part of code:

    public event NotifyCallback Notify
    {
        add    { s_notify = value; }
        remove { /*  */ }
    }

into:

    public event NotifyCallback Notify
    {
        add    { s_notify += value; }
        remove { s_notify -= value; }
    }

Right now, events are not added to the list, but s_notify is set to fire a different event handler on each add.

Groo
Thanks you a lot! It works :)
Maiori
As a side note, IMHO the example code in the link you provided is rather incomplete (e.g. missing event remove accessor, and what's the deal with "This call will throw an exception" in FireNewBroadcastedMessageEvent? Wouldn't it be better to simply check if s_notify is null?). Try to google for some more examples to get a broader picture.
Groo