Esempio n. 1
0
        private ICriticalSectionContext CreateClientCriticalSection()
        {
            if (IsClientCriticalSectionActive())
            {
                throw new CriticalSectionException("Only one client critical section context can be active at a time");
            }

            _clientCriticalSectionContext = new CriticalSectionContext(_criticalSectionRepository,
                                                                       _taskExecutionInstance,
                                                                       _taskExecutionOptions,
                                                                       CriticalSectionType.Client);

            return(_clientCriticalSectionContext);
        }
Esempio n. 2
0
        public ICriticalSectionContext CreateCriticalSection()
        {
            if (!IsExecutionContextActive)
            {
                throw new ExecutionException(NotActiveMessage);
            }

            if (IsUserCriticalSectionActive())
            {
                throw new CriticalSectionException("Only one user critical section context can be active at a time for one context. Check that you are not nesting critical sections with the same context.");
            }

            _userCriticalSectionContext = new CriticalSectionContext(_criticalSectionRepository,
                                                                     _taskExecutionInstance,
                                                                     _taskExecutionOptions,
                                                                     CriticalSectionType.User);

            return(_userCriticalSectionContext);
        }