public void AddPint() { if (pintCount >= (MaxPints - 1)) { watch.Stop(); DishCompleted?.Invoke(this, EventArgs.Empty, watch.ElapsedMilliseconds); } PintStarted?.Invoke(this, EventArgs.Empty); pintCount++; PintCompleted?.Invoke(this, new PintCompletedArgs()); if (pintCount == (MaxPints / 2)) { Dishhalfway?.Invoke(this, EventArgs.Empty); } }
public void AddPint() { if (pintCount >= MaxPints) { throw new Exception("Dish full, order cancelled"); } PintStarted?.Invoke(this, new PintStartedArgs()); pintCount++; PintCompleted?.Invoke(this, new PintCompletedArgs()); int halfWayPoint = MaxPints % 2 == 0 ? MaxPints / 2 : MaxPints / 2 + 1; if (PintCount == halfWayPoint) { DishHalfway?.Invoke(this, EventArgs.Empty); } if (PintCount >= MaxPints) { DishCompleted?.Invoke(this, new DishCompletedArgs(dishStarted)); } }