void CarsStart() { for (int i = 0; i < countCars; i++) { wakeEvents.Add(new AutoResetEvent(false)); var cateringCar = new CateringCar(i); cateringCar.LocationVertex = transportMotion.GetHomeVertex(); cars.TryAdd(cateringCar.CarId, cateringCar); tokens.TryAdd(cateringCar.CarId, new CancellationTokenSource()); DoCatering(cateringCar, wakeEvents[i]).Start(); } }
void CarsStart() { for (int i = 0; i < countCars; i++) { wakeEvents.Add(new AutoResetEvent(false)); var fuelTruckCar = new FuelTruckCar(i); fuelTruckCar.LocationVertex = transportMotion.GetHomeVertex(); cars.TryAdd(fuelTruckCar.CarId, fuelTruckCar); tokens.TryAdd(fuelTruckCar.CarId, new CancellationTokenSource()); DoRefuel(fuelTruckCar, wakeEvents[i]).Start(); } SendLogMessage(String.Format("Создали {0} машинок!", countCars)); }
void CarsStart() { for (int i = 0; i < countCars; i++) { var busCar = new BusCar(); busCar.LocationVertex = transportMotion.GetHomeVertex(); cars.TryAdd(busCar.CarId, busCar); busCar.CarTools = new CarTools() { AirplaneResponse = new AutoResetEvent(false), WakeEvent = new AutoResetEvent(false), StorageResponse = new AutoResetEvent(false), TokenSource = new CancellationTokenSource() }; DoWork(busCar, cars[busCar.CarId].CarTools.WakeEvent).Start(); } }