Beispiel #1
0
        private async void LifeStep()
        {
            for (var countDown = 9; countDown >= 0; countDown--)
            {
                OnCountdownChanged?.Invoke(this, countDown);
                await Task.Delay(TimeSpan.FromSeconds(0.4));
            }
            using var _ = await _lock.DisposableEnter();

            var changes = GameOfLife.NextGenerationChanges(_theBoard);

            ApplyChanges(changes);
            LifeStep();
        }
        public async Task <IServiceProvider> GetScope(HubCallerContext context)
        {
            using var _ = await theLock.DisposableEnter();

            var connectionId = context.ConnectionId;

            if (scopeDictionay.TryGetValue(connectionId, out var scope))
            {
                Logger.LogDebug($"Re-using scope for {connectionId}");
                return(scope.ServiceProvider);
            }

            Logger.LogDebug($"Creating scope for {connectionId}");
            scope = serviceProvider.CreateScope();
            context.ConnectionAborted.Register(() => DisposeServiceForConnection(context.ConnectionId));
            scopeDictionay = scopeDictionay.Add(connectionId, scope);
            return(scope.ServiceProvider);
        }
Beispiel #3
0
 private Task <IDisposable> Lock() => _lock.DisposableEnter();
Beispiel #4
0
 private Task <IDisposable> Lock()
 {
     return(_lock.DisposableEnter());
 }