Example #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Please insert the number of car threads");
            int noOfThreads = Int32.Parse(Console.ReadLine());

            Console.WriteLine("Please insert running time in minutes (ex. 15.5)");
            float runningTime = float.Parse(Console.ReadLine());

            Console.WriteLine("Making {0} threads and running the for {1} minutes", noOfThreads, runningTime);


            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            CarEngine e = new CarEngine(noOfThreads, runningTime);

            e.Start();
            stopwatch.Stop();
            Logger logger = new Logger(e.AllLogs);


            logger.LogToFile(@"output.txt", e.Money);
            Console.WriteLine("Total excecution time was {0} ms", stopwatch.ElapsedMilliseconds);
            Console.WriteLine("Total earnings were {0} Euros", e.Money);
            Console.ReadLine();
        }
Example #2
0
            //System.Timers.Timer timer;

            public ManagingThread(int id, ConcurrentDictionary <int, Client> clients, List <Depot> depots, List <Hotspot> hotspots, DateTime startTimeCar, Router router, CarEngine carEngine)
            {
                ID                = id;
                Money             = 0f;
                this.clients      = clients;
                this.depots       = depots;
                this.hotspots     = hotspots;
                this.startTimeCar = startTimeCar;
                endTimeCompute    = DateTime.Now.AddMinutes(runTime);
                this.carEngine    = carEngine;
                this.router       = router;
                //this.timer = timer;
            }