Server.Timer.Stop C# (CSharp) Méthode

Stop() public méthode

public Stop ( ) : void
Résultat void
        public void Stop()
        {
            if (this.watch.IsRunning) {
                this.watch.Stop();
                if (this.average == 0) {
                    this.elapsed = this.watch.ElapsedTicks;
                } else {
                    this.elapsedCollection.Add(this.watch.ElapsedTicks);
                    if (Time.Now - this.start >= this.average) {
                        this.CalculateAverage();
                        this.elapsedCollection.Clear();
                        this.start = Time.Now;
                    }
                }
            }
        }

Usage Example

Exemple #1
0
        static void WebServerOnDisconnect(int id)
        {
            _connectedIds.Remove(id);
            _playerDatas.Remove(id);

            // Tell other players about the disconnection
            _bitBuffer.Clear();
            _bitBuffer.AddByte(4);
            _bitBuffer.AddUShort((ushort)id);
            _bitBuffer.ToArray(_buffer);
            _webServer.SendAll(_connectedIds, new ArraySegment <byte>(_buffer, 0, 3));

            // Check if we have less than 2 players and should cancel the game
            if (_currentState != GameState.Waiting && _connectedIds.Count < 2)
            {
                beginTimer?.Stop();
                _currentState = GameState.Waiting;
                SendStateUpdate(_currentState);
            }
        }
All Usage Examples Of Server.Timer::Stop