using System.Collections.Generic;
using System.Linq;
using System.Text;
{
// define the delegate
public delegate void TicketSoldFinished();
{
public SimonTicketShop(int ticketCount)
{
m_TicketCount = ticketCount;
m_OnTicketSoldFinished = null;
}
{
for(int i= m_TicketCount; i>0; --i)
{
Console.WriteLine("{0}", i);
System.Threading.Thread.Sleep(500);
}
{
m_OnTicketSoldFinished();
}
}
private int m_TicketCount;
}
{
public ShopManager()
{
{
Console.WriteLine("All the tickets are sold. :-)");
return;
}
}
{
static void Main(string[] args)
{
ShopManager shopManager = new ShopManager();
SimonTicketShop simonTicketShop = new SimonTicketShop(20); //20 tickets initially
simonTicketShop.m_OnTicketSoldFinished += shopManager.AllTicketsAreSold;
aThread.Start();
}
}
}