views:

214

answers:

1

I'm an Objective-C developer porting an application to the .Net world. In my Obj-C application, I use NSNotification objects to communicate asynchronously between a handful of objects. Is there some way to do something similar in the .Net world (more specifically, using the C# language)? The fundamental approach is that one object posts a notification that one or more objects listen for.

There's probably an obvious way of doing this, but I haven't found it yet...

+1  A: 

Using Delegates in C# or VB.NET is the equivalent language integrated feature. You can create events by defining or using a predefined Delegate to define the "notification" that can be published and subscribed to. Then define an event on a class that you can subscribe to and raise. The MSDN documentation has a good overview once you find it here. A good example is here.

-scott

scott
@Scott: looks like you used the same link twice...
Mitch Wheat
Thanks. I fixed it. Not sure how I did that :S
scott