/// <summary>
        /// Constructor for ServiceLock processor.
        /// </summary>
        /// <param name="numberThreads">The number of threads allocated to the processor.</param>
        /// <param name="terminationEvent">Stop signal</param>
        public ServiceLockProcessor(int numberThreads, ManualResetEvent terminationEvent)
        {
            _terminationEvent = terminationEvent;
            _threadStop       = new ManualResetEvent(false);

            _threadPool = new ServiceLockThreadPool(numberThreads);
            _threadPool.ThreadPoolName = "ServiceLock Pool";

            ServiceLockFactoryExtensionPoint ep = new ServiceLockFactoryExtensionPoint();

            object[] factories = ep.CreateExtensions();

            if (factories == null || factories.Length == 0)
            {
                // No extension for the ServiceLock processor.
                Platform.Log(LogLevel.Warn, "No ServiceLockFactory Extension found.");
            }
            else
            {
                foreach (object obj in factories)
                {
                    IServiceLockProcessorFactory factory = obj as IServiceLockProcessorFactory;
                    if (factory != null)
                    {
                        ServiceLockTypeEnum type = factory.GetServiceLockType();
                        _extensions.Add(type, factory);
                    }
                    else
                    {
                        Platform.Log(LogLevel.Error, "Unexpected incorrect type loaded for extension: {0}",
                                     obj.GetType());
                    }
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Constructor for ServiceLock processor.
        /// </summary>
        /// <param name="numberThreads">The number of threads allocated to the processor.</param>
        /// <param name="terminationEvent">Stop signal</param>
        public ServiceLockProcessor(int numberThreads, ManualResetEvent terminationEvent)
        {
            _terminationEvent = terminationEvent;
            _threadStop = new ManualResetEvent(false);

			_threadPool = new ServiceLockThreadPool(numberThreads);
        	_threadPool.ThreadPoolName = "ServiceLock Pool";

            ServiceLockFactoryExtensionPoint ep = new ServiceLockFactoryExtensionPoint();
            object[] factories = ep.CreateExtensions();

            if (factories == null || factories.Length == 0)
            {
                // No extension for the ServiceLock processor. 
                Platform.Log(LogLevel.Warn, "No ServiceLockFactory Extension found.");
            }
            else
            {
                foreach (object obj in factories)
                {
                    IServiceLockProcessorFactory factory = obj as IServiceLockProcessorFactory;
                    if (factory != null)
                    {
                        ServiceLockTypeEnum type = factory.GetServiceLockType();
                        _extensions.Add(type, factory);
                    }
                    else
                        Platform.Log(LogLevel.Error, "Unexpected incorrect type loaded for extension: {0}",
                                     obj.GetType());
                }
            }
        }