public async Task <ICollaborationService> CreateServiceAsync(CollaborationSession sessionContext, CancellationToken cancellationToken)
        {
            if (sessionContext == null)
            {
                throw new ArgumentNullException(nameof(sessionContext));
            }

            await EnsureViewImportsCopiedAsync(sessionContext, cancellationToken);

            _sessionAccessor.SetSession(sessionContext);
            var sessionDetector = new SessionActiveDetector(() => _sessionAccessor.SetSession(session: null));

            return(sessionDetector);
        }
        public Task <ICollaborationService> CreateServiceAsync(CollaborationSession sessionContext, CancellationToken cancellationToken)
        {
            if (sessionContext == null)
            {
                throw new ArgumentNullException(nameof(sessionContext));
            }

#pragma warning disable CA2000 // Dispose objects before losing scope
            var cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
#pragma warning restore CA2000 // Dispose objects before losing scope
            _viewImportsCopyTask = EnsureViewImportsCopiedAsync(sessionContext, cts.Token);

            _sessionAccessor.SetSession(sessionContext);
            var sessionDetector = new SessionActiveDetector(() =>
            {
                cts.Cancel();
                _sessionAccessor.SetSession(session: null);
            });
            return(Task.FromResult <ICollaborationService>(sessionDetector));
        }
Esempio n. 3
0
        public Task <ICollaborationService> CreateServiceAsync(CollaborationSession sessionContext, CancellationToken cancellationToken)
        {
            if (sessionContext == null)
            {
                throw new ArgumentNullException(nameof(sessionContext));
            }

            var cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);

            _viewImportsCopyTask = EnsureViewImportsCopiedAsync(sessionContext, cts.Token);

            _sessionAccessor.SetSession(sessionContext);
            var sessionDetector = new SessionActiveDetector(() =>
            {
                cts.Cancel();
                _sessionAccessor.SetSession(session: null);
            });

            return(Task.FromResult <ICollaborationService>(sessionDetector));
        }