Exemple #1
0
 public Ferry()
 {
     FerryThread  = new Thread(new ThreadStart(MoveFerry));
     Coast        = CoastEnum.WestCoast;
     _ferryAction = Actions.FerryWait;
     Cars         = new Stack <Car>();
     _timer       = new Stopwatch();
     _timer.Start();
 }
Exemple #2
0
 public Ferry()
 {
     FerryThread          = new Thread(new ThreadStart(MoveFerry));
     FerryThread.Priority = ThreadPriority.AboveNormal;
     Coast  = CoastEnum.WestCoast;
     Cars   = new Stack <Car>();
     _timer = new Stopwatch();
     _timer.Start();
 }
Exemple #3
0
        private void MoveEastCoast()
        {
            Console.WriteLine("Ferry Move to East Coast");
            Thread.Sleep(1000);

            Coast = CoastEnum.EastCoast;

            Monitor.PulseAll(this);
            Monitor.Wait(this);
            MoveFerry();
        }
Exemple #4
0
 private void MoveEastCoast()
 {
     lock (this)
     {
         _ferryAction = Actions.FerryMove;
     }
     Console.WriteLine(" Ferry Move to East Coast");
     Thread.Sleep(1000);
     lock (this)
     {
         Coast        = CoastEnum.EastCoast;
         _ferryAction = Actions.FerryWait;
     }
     MoveFerry();
 }
Exemple #5
0
        private void MoveWestCoast()
        {
            Console.WriteLine("Ferry Move to West Coast");
            Thread.Sleep(1000);
            _timer.Restart();
            Coast = CoastEnum.WestCoast;
            ++_courses;

            Monitor.PulseAll(this);
            //if (_courses == (CarsCount % FerryCapacity + 1))
            //{
            //    FerryThread.Abort();
            //}
            Monitor.Wait(this);
            MoveFerry();
        }
Exemple #6
0
        private void MoveWestCoast()
        {
            lock (this)
            {
                _ferryAction = Actions.FerryMove;
            }
            Console.WriteLine(" Ferry Move to West Coast");
            Thread.Sleep(1000);
            lock (this)
            {
                _courses = 0;
                _timer.Restart();
                Coast = CoastEnum.WestCoast;

                _ferryAction = Actions.FerryWait;
            }
            MoveFerry();
        }
        private void MoveWestCoast()
        {
            Console.WriteLine("Ferry Move to West Coast");
            Thread.Sleep(1000);
            _timer.Restart();
            Coast = CoastEnum.WestCoast;
            ++_courses;

            Monitor.PulseAll(this);
            //if (_courses == (CarsCount % FerryCapacity + 1))
            //{
            //    FerryThread.Abort();
            //}
            Monitor.Wait(this);
            MoveFerry();
        }
        private void MoveEastCoast()
        {
            Console.WriteLine("Ferry Move to East Coast");
            Thread.Sleep(1000);

            Coast = CoastEnum.EastCoast;

            Monitor.PulseAll(this);
            Monitor.Wait(this);
            MoveFerry();
        }
        private void MoveWestCoast()
        {
            lock(this)
            {
                _ferryAction = Actions.FerryMove;
            }
                Console.WriteLine(" Ferry Move to West Coast");
                Thread.Sleep(1000);
            lock(this)
            {
                _courses = 0;
                _timer.Restart();
                Coast = CoastEnum.WestCoast;

                _ferryAction = Actions.FerryWait;
            }
                MoveFerry();
        }
 private void MoveEastCoast()
 {
     lock(this)
     {
         _ferryAction = Actions.FerryMove;
     }
         Console.WriteLine(" Ferry Move to East Coast");
         Thread.Sleep(1000);
     lock(this)
     {
         Coast = CoastEnum.EastCoast;
         _ferryAction = Actions.FerryWait;
     }
         MoveFerry();
 }