protected TransportDuplexSessionChannel(
           ChannelManagerBase manager, 
           ITransportFactorySettings settings,
           EndpointAddress localAddress, 
           Uri localVia, 
           EndpointAddress remoteAddresss, 
           Uri via)
         : base(manager, remoteAddresss, via, settings.ManualAddressing, settings.MessageVersion)
 {
     this.localAddress = localAddress;
     this.localVia = localVia;
     this.bufferManager = settings.BufferManager;
     this.sendLock = new ThreadNeutralSemaphore(1);
     this.messageEncoder = settings.MessageEncoderFactory.CreateSessionEncoder();
     this.Session = new ConnectionDuplexSession(this);
 }
示例#2
0
        private static void OnEnteredAsync(object state, TimeoutException exception)
        {
            ThreadNeutralSemaphore.EnterAsyncData enterAsyncDatum = (ThreadNeutralSemaphore.EnterAsyncData)state;
            ThreadNeutralSemaphore semaphore = enterAsyncDatum.Semaphore;
            Exception exception1             = exception;

            if (exception != null && !semaphore.RemoveWaiter(enterAsyncDatum.Waiter))
            {
                exception1 = null;
            }
            if (semaphore.aborted)
            {
                exception1 = semaphore.CreateObjectAbortedException();
            }
            enterAsyncDatum.Callback(enterAsyncDatum.State, exception1);
        }
示例#3
0
        public bool TryEnter()
        {
            bool flag;

            lock (this.ThisLock)
            {
                if (this.count >= this.maxCount)
                {
                    flag = false;
                }
                else
                {
                    ThreadNeutralSemaphore threadNeutralSemaphore = this;
                    threadNeutralSemaphore.count = threadNeutralSemaphore.count + 1;
                    flag = true;
                }
            }
            return(flag);
        }
示例#4
0
        public int Exit()
        {
            int num;
            int num1 = -1;

            lock (this.ThisLock)
            {
                if (!this.aborted)
                {
                    if (this.count != 0)
                    {
                        if (this.waiters == null || this.waiters.Count == 0)
                        {
                            ThreadNeutralSemaphore threadNeutralSemaphore = this;
                            threadNeutralSemaphore.count = threadNeutralSemaphore.count - 1;
                            num = this.count;
                        }
                        else
                        {
                            AsyncWaitHandle asyncWaitHandle = this.waiters.Dequeue();
                            num1 = this.count;
                            asyncWaitHandle.Set();
                            return(num1);
                        }
                    }
                    else
                    {
                        string invalidSemaphoreExit = InternalSR.InvalidSemaphoreExit;
                        throw Fx.Exception.AsError(new SynchronizationLockException(invalidSemaphoreExit));
                    }
                }
                else
                {
                    num = num1;
                }
            }
            return(num);
        }
 public EnterAsyncData(ThreadNeutralSemaphore semaphore, AsyncWaitHandle waiter, FastAsyncCallback callback, object state)
 {
     this.Waiter = waiter;
     this.Semaphore = semaphore;
     this.Callback = callback;
     this.State = state;
 }
        WorkflowServiceInstance(Activity workflowDefinition, WorkflowIdentity definitionIdentity, Guid instanceId, WorkflowServiceHost serviceHost, PersistenceContext persistenceContext)
            : base(workflowDefinition, definitionIdentity)
        {
            this.serviceHost = serviceHost;
            this.instanceId = instanceId;
            this.persistTimeout = serviceHost.PersistTimeout;
            this.trackTimeout = serviceHost.TrackTimeout;
            this.bufferedReceiveManager = serviceHost.Extensions.Find<BufferedReceiveManager>();

            if (persistenceContext != null)
            {
                this.persistenceContext = persistenceContext;
                this.persistenceContext.Closed += this.OnPersistenceContextClosed;
            }

            this.thisLock = new object();
            this.pendingRequests = new List<WorkflowOperationContext>();
            this.executorLock = new WorkflowExecutionLock(this);
            this.activeOperationsLock = new object();
            this.acquireReferenceSemaphore = new ThreadNeutralSemaphore(1);
            this.acquireLockTimeout = TimeSpan.MaxValue;

            // Two initial references are held:
            // The first referenceCount is owned by UnloadInstancePolicy (ReleaseInstance)
            this.referenceCount = 1;
            // The second referenceCount is owned by the loader / creator of the instance.
            this.TryAddReference();
        }
 public InstanceThrottle(int maxCount, WorkflowServiceHost serviceHost)
 {
     this.throttle = new ThreadNeutralSemaphore(maxCount);
     this.maxCount = maxCount;
     this.warningRestoreLimit = (int)Math.Floor(0.7 * (double)maxCount);
     this.serviceHost = serviceHost;
 }
 protected ReceiveContext()
 {
     this.thisLock = new object();
     this.State = ReceiveContextState.Received;
     this.stateLock = new ThreadNeutralSemaphore(1);
 }
 public InstanceThrottle(int maxCount)
 {
     this.throttle = new ThreadNeutralSemaphore(maxCount);
     this.maxCount = maxCount;
     this.warningRestoreLimit = (int) Math.Floor((double) (0.7 * maxCount));
 }
 private WorkflowServiceInstance(Activity workflowDefinition, Guid instanceId, WorkflowServiceHost serviceHost, PersistenceContext persistenceContext) : base(workflowDefinition)
 {
     this.serviceHost = serviceHost;
     this.instanceId = instanceId;
     this.persistTimeout = serviceHost.PersistTimeout;
     this.trackTimeout = serviceHost.TrackTimeout;
     this.bufferedReceiveManager = serviceHost.Extensions.Find<System.ServiceModel.Activities.Dispatcher.BufferedReceiveManager>();
     if (persistenceContext != null)
     {
         this.persistenceContext = persistenceContext;
         this.persistenceContext.Closed += new EventHandler(this.OnPersistenceContextClosed);
     }
     this.thisLock = new object();
     this.pendingRequests = new List<WorkflowOperationContext>();
     this.executorLock = new WorkflowExecutionLock(this);
     this.activeOperationsLock = new object();
     this.acquireReferenceSemaphore = new ThreadNeutralSemaphore(1);
     this.acquireLockTimeout = TimeSpan.MaxValue;
     this.referenceCount = 1;
     this.TryAddReference();
 }