public override void Dispose() { if (IsDisposed) { return; } IsDisposed = true; IsRunning = false; _tokenSource.Cancel(); GenericProcessManager.Destroy(_playerAi); }
public AiPlayer(Field currentField, GameMain gameMain, string fileName) : base(currentField, gameMain) { _playerAi = new Process(); GenericProcessManager.Add(_playerAi); _fileName = fileName; _inputQueue = new ConcurrentQueue <string>(); _tokenSource = new CancellationTokenSource(); _token = _tokenSource.Token; _writeTask = Task.Factory.StartNew(WriteStanderdInputFromQueue, _token); }