using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
public delegate void SomeEvent(object sender, EventArgs e);
class EventListener
{
public void EventFired(object sender, EventArgs e)
{
Console.WriteLine("Event recieved!");
}
public void Attach(EventSender es)
{
es.EventRecieved += new SomeEvent(this.EventFired);
}
}
class EventSender
{
public event SomeEvent EventRecieved;
public void DoStuff()
{
if (EventRecieved != null)
EventRecieved(this, EventArgs.Empty);
}
}
class Program
{
static void Main(string[] args)
{
EventListener el = new EventListener();
EventSender es = new EventSender();
el.Attach(es);
es.DoStuff();
}
}
}