public void OnShipmentDequeued(object sender, StationShipmentEventArgs eventArgs) { var shipmentDequeuedFromStation = ShipmentDequeuedFromStation; if (shipmentDequeuedFromStation != null) { shipmentDequeuedFromStation(sender, eventArgs); } }
public Shipment DeliverShipmentToTrain() { try { Shipment shipment; if (_queStationShipment.TryDequeue(out shipment)) { if (shipment != null) { StationShipmentEventArgs args = new StationShipmentEventArgs(shipment.SourceStation.StationId, shipment.DestinationStation.StationId); args.Message = shipment + " Shipment queued at " + shipment.SourceStation; args.DeliveredShipment = shipment; OnShipmentDequeued(this, args); return(shipment); } } throw new Exception("Station has not shipment now."); } catch (Exception) { throw; } }