Jedhi Posted November 3, 2003 Posted November 3, 2003 If you are looking in a design perspective, where you must write a program in C# that needs to do something else when an event appear (callback). How would you then prefer to make the archittecture ? With Delegates or virtual functions ? Quote
Cywizz Posted November 12, 2003 Posted November 12, 2003 I think you might be interested in the Observer pattern (subscriber pattern) http://msdn.microsoft.com/architecture/patterns/DesObserver/ This allows your worker objects to subscribe to a publisher object. Once something happens, the publisher will raise the relevant event, and all the workers, that subscribed to the event, will be notified. Hope it helps Quote Howzit??
*Gurus* divil Posted November 13, 2003 *Gurus* Posted November 13, 2003 A common and recommended design pattern in .NET is to have events raised by On[eventname] functions in the class. These routines should be virtual, so one can hook events externally or actually derive from the class and override. One can also then not call the base method and avoid the overhead of the delegates being called. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Jedhi Posted November 13, 2003 Author Posted November 13, 2003 Thanks ! Do you know any good book about observer pattern, that you could recommand. I does not matter whether it is written in C++ or C#. Quote
Optikal Posted November 13, 2003 Posted November 13, 2003 That link provides about all the information you could possibly need to know, including a link to another article about implementing it in .Net. Quote
Jedhi Posted November 14, 2003 Author Posted November 14, 2003 I was more thinking of is this book described in the link better than the design patterns book written by Erich Gamma http://www.amazon.co.uk/exec/obidos/ASIN/0201633612/qid=1068799315/sr=2-1/ref=sr_2_3_1/026-7894076-6806810 Or is the book about Erich Gamma a must ?? Or Do you prefer other books ? Quote
Jedhi Posted November 24, 2003 Author Posted November 24, 2003 I have now been reading this book. All along I have been looking into many things and have decided that a baseclass and a container class with some event was the best solution. Until I read this book. Here they recommand to use Observer pattern with delegates and event instead of a base class and an observer interface if you only have single inheritance. Furthermore they write there is no need for Subject, Subjecthelper and observer because the common language runtime makes them obsolete. This means that the subject that is a baseclass goes out !!!!! I do not get it! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.