コード例 #1
0
ファイル: RaceProcessor.cs プロジェクト: Cycli/Cycli
        public void AbandonRider(RideProcessor rp)
        {
            try
            {
                _RaceSpotLock.EnterWriteLock();
                // set this rider as abandoned
                _RaceSpots[rp.UserId].a = true;
                // Remove the handlers
                rp.RiderInactiveEvent -= this.AbandonRider;
                rp.SpotDataEvent -= this.UpdateSpotData;

            }
            finally
            {
                Debug.WriteLine("Rider Abandoned " + this.Race.Name + "  " + rp.UserId);

                _RaceSpotLock.ExitWriteLock();
            }
        }
コード例 #2
0
ファイル: CycliManager.cs プロジェクト: Cycli/Cycli
 private RideProcessor ActivateUserRider(string userId)
 {
     RideProcessor processor = null;
       try
       {
     _rideProcessLock.EnterWriteLock();
     // rideprocessor lock should already be in write mode
     processor = new RideProcessor(userId);
       //       check if already registered
     if (!_RideProcessors.ContainsKey(userId)) {
     _RideProcessors.Add(userId, processor);
     }
       }
       finally
       {
     _rideProcessLock.ExitWriteLock();
       }
       return processor;
 }
コード例 #3
0
ファイル: RaceProcessor.cs プロジェクト: Cycli/Cycli
        public void UpdateSpotData(RideProcessor rideProcessor)
        {
            // This method is called by any attached ride processor
            // ride processor is only attached at race start if rider status flag is set
            // to started, so we can update spots without checking started flag here

            try
            {
                _SpotLock.EnterWriteLock();
                // return true if finished
                Spot sp = rideProcessor.SpotData;
                // careful here - it's possible for sp.t to have been set before the racestartticks
                // due to locking, so we have to allow for deltaticks to be negative
                // which, as this is all unsigned, with give a massive number!!
                // only process if sp.t > _racestartticks
                if (sp.t > _raceStartTicks)
                {

                    if (IsRiderFinished(sp.id))
                    {
                        rideProcessor.SpotDataEvent -= this.UpdateSpotData;
                        rideProcessor.RiderInactiveEvent -= this.AbandonRider;
                    }
                    else
                    {
                        _Spots[sp.id] = sp;
                    }
                }
            }
            finally
            {
                _SpotLock.ExitWriteLock();
            }
        }