private void BackgroundProcessing(object timer) { var currentTime = DateTime.Now.ToUniversalTime(); if (_lastUpdateDate == null) { var gameContext = _serviceProvider.GetRequiredService <GameContext>(); var gameInfo = gameContext.GameInfo.GetOneAsync(x => x.Actual).Result; if (gameInfo == null) { gameInfo = new Game.Entities.GameInfo() { Id = Guid.NewGuid().ToString(), Actual = true, LastUpdateDate = currentTime.Date }; gameContext.GameInfo.InsertOneAtomicallyAsync(gameInfo).Wait(); } _lastUpdateDate = gameInfo.LastUpdateDate; } var passed = (currentTime - _timeStamp).TotalSeconds; _counter += passed; if (_counter >= 10) { _queueService.QueueProcessing(_counter); _counter = 0; } _battleService.EngineTimeProcessing(passed); _timeStamp = currentTime; if (currentTime.Date != _lastUpdateDate.Value.Date) { _lastUpdateDate = currentTime.Date; Task.Run(async() => await DailyUpdateAsync(_lastUpdateDate.Value)); } }