Пример #1
0
        internal static void ApplyDispatchBehavior(ThreadPoolSynchronizer synchronizer,uint poolSize,Type type,string poolName,DispatchRuntime dispatch)
        {
            Debug.Assert(dispatch.SynchronizationContext == null);
             int maxConcurrentCalls = 16;
             if(dispatch.ChannelDispatcher.ServiceThrottle != null)
             {
            maxConcurrentCalls = dispatch.ChannelDispatcher.ServiceThrottle.MaxConcurrentCalls;
             }
             if(maxConcurrentCalls < poolSize)
             {
            throw new InvalidOperationException("The throttle should allow at least as many concurrent calls as the pool size");
             }

             if(HasSynchronizer(type))
             {
            Debug.Assert(GetSynchronizer(type) == synchronizer);
             }

             if(HasSynchronizer(type) == false)
             {
            m_Synchronizers[type] = synchronizer;
             }
             dispatch.SynchronizationContext = synchronizer;
        }
Пример #2
0
            internal WorkerThread(string name,ThreadPoolSynchronizer context)
            {
                m_Context = context;

                m_EndLoop = false;
                m_ThreadObj = null;

                m_ThreadObj = new Thread(Run);
                m_ThreadObj.IsBackground = true;
                m_ThreadObj.Name = name;
                m_ThreadObj.Start();
            }