public CallbackThreadPoolBehaviorAttribute(uint poolSize, Type clientType, string poolName) : base(poolSize, clientType, poolName)
 {
     AppDomain.CurrentDomain.ProcessExit += delegate
     {
         ThreadPoolHelper.CloseThreads(base.ServiceType);
     };
 }
예제 #2
0
 void IServiceBehavior.Validate(ServiceDescription description, ServiceHostBase serviceHostBase)
 {
     serviceHostBase.Closed += delegate
     {
         ThreadPoolHelper.CloseThreads(this.ServiceType);
     };
 }
 protected override ThreadPoolSynchronizer ProvideSynchronizer()
 {
     if (!ThreadPoolHelper.HasSynchronizer(base.ServiceType))
     {
         return(new PrioritySynchronizer(base.PoolSize, base.PoolName));
     }
     return(ThreadPoolHelper.GetSynchronizer(base.ServiceType));
 }
예제 #4
0
 protected virtual ThreadPoolSynchronizer ProvideSynchronizer()
 {
     if (!ThreadPoolHelper.HasSynchronizer(this.ServiceType))
     {
         return(new ThreadPoolSynchronizer(this.PoolSize, this.PoolName));
     }
     return(ThreadPoolHelper.GetSynchronizer(this.ServiceType));
 }
예제 #5
0
        internal static void ApplyDispatchBehavior(ThreadPoolSynchronizer synchronizer, uint poolSize, Type type, string poolName, DispatchRuntime dispatch)
        {
            int num = 16;

            if (dispatch.ChannelDispatcher.ServiceThrottle != null)
            {
                num = dispatch.ChannelDispatcher.ServiceThrottle.MaxConcurrentCalls;
            }
            if ((long)num < (long)((ulong)poolSize))
            {
                throw new InvalidOperationException("The throttle should allow at least as many concurrent calls as the pool size");
            }
            ThreadPoolHelper.HasSynchronizer(type);
            if (!ThreadPoolHelper.HasSynchronizer(type))
            {
                ThreadPoolHelper.m_Synchronizers[type] = synchronizer;
            }
            dispatch.SynchronizationContext = synchronizer;
        }
예제 #6
0
 void IContractBehavior.ApplyDispatchBehavior(ContractDescription description, ServiceEndpoint endpoint, DispatchRuntime dispatchRuntime)
 {
     this.PoolName = (this.PoolName ?? ("Pool executing endpoints of " + this.ServiceType));
     ThreadPoolHelper.ApplyDispatchBehavior(this.ProvideSynchronizer(), this.PoolSize, this.ServiceType, this.PoolName, dispatchRuntime);
 }