예제 #1
0
        public void Execute()
        {
            eventArgs           = cluster.GetEventArgs();
            segment             = segmentOrig = eventArgs.UserToken as BufferSegment;
            eventArgs.UserToken = this;

            if (cluster.HasBufferChanged(segment))
            {
                // Reset buffer in SizeBuffer().
                segment.buffer = null;
                segment.offset = 0;
                segment.size   = 0;
            }

            Policy policy = GetPolicy();

            timeout = policy.timeout;

            if (timeout > 0)
            {
                watch = Stopwatch.StartNew();
                AsyncTimeoutQueue.Instance.Add(this, timeout);
            }

            ExecuteCommand();
        }
예제 #2
0
        public void Execute()
        {
            eventArgs           = cluster.GetEventArgs();
            segment             = segmentOrig = eventArgs.UserToken as BufferSegment;
            eventArgs.UserToken = this;

            if (cluster.HasBufferChanged(segment))
            {
                // Reset buffer in SizeBuffer().
                segment.buffer = null;
                segment.offset = 0;
                segment.size   = 0;
            }

            // In async mode, totalTimeout and socketTimeout are mutually exclusive.
            // If totalTimeout is defined, socketTimeout is ignored.
            // This is done so we can avoid having to declare usingSocketTimeout as
            // volatile and because enabling both timeouts together has no real value.
            if (policy.totalTimeout > 0)
            {
                watch = Stopwatch.StartNew();
                AsyncTimeoutQueue.Instance.Add(this, policy.totalTimeout);
            }
            else if (policy.socketTimeout > 0)
            {
                usingSocketTimeout = true;
                watch = Stopwatch.StartNew();
                AsyncTimeoutQueue.Instance.Add(this, policy.socketTimeout);
            }
            ExecuteCommand();
        }
        public void Execute()
        {
            eventArgs           = cluster.GetEventArgs();
            eventArgs.UserToken = this;
            dataBuffer          = eventArgs.Buffer;

            if (dataBuffer != null && cluster.HasBufferChanged(dataBuffer))
            {
                // Reset dataBuffer in SizeBuffer().
                dataBuffer = null;
            }

            Policy policy = GetPolicy();

            timeout = policy.timeout;

            if (timeout > 0)
            {
                watch = Stopwatch.StartNew();
                AsyncTimeoutQueue.Instance.Add(this, timeout);
            }

            ExecuteCommand();
        }