public bool GateOpen(Horses horses) { Console.WriteLine("Stable gate is Opening"); Thread.Sleep(2000); Console.WriteLine("Stable gate is Opened"); OnGateOpened(horses); return(IsOpen = true); }
static void Main(string[] args) { Stablegate stablegate = new Stablegate(); Horses horses = new Horses(); try { stablegate.OnGateOpening += horses.OnGateOpening; stablegate.GateOpen(horses); } catch (Exception ex) { Console.Write(ex.Message); } finally { stablegate.GateClose(); } Console.Read(); }
protected virtual void OnGateOpened(Horses horses) { OnGateOpening?.Invoke(this, new StablegateEventArgs { HorseCount = horses.HorseList().Count }); }