Пример #1
0
        public bool Continue(WebOperation next)
        {
            lock (this) {
                if (Closed)
                {
                    return(false);
                }

                Debug($"WC CONTINUE: Cnc={ID} connected={socket?.Connected} next={next?.ID} current={currentOperation?.ID}");
                if (socket == null || !socket.Connected || !PrepareSharingNtlm(next))
                {
                    Close(true);
                    return(false);
                }

                currentOperation = next;

                if (next == null)
                {
                    return(true);
                }

                // Ok, we got another connection.  Let's run it!
                next.RegisterRequest(ServicePoint, this);
            }

            next.Run();
            return(true);
        }
Пример #2
0
        public bool StartOperation(WebOperation operation, bool reused)
        {
            lock (this) {
                if (Closed)
                {
                    return(false);
                }
                if (Interlocked.CompareExchange(ref currentOperation, operation, null) != null)
                {
                    return(false);
                }

                idleSince = DateTime.UtcNow + TimeSpan.FromDays(3650);

                if (reused && !PrepareSharingNtlm(operation))
                {
                    Debug($"WC START - CAN'T REUSE: Cnc={ID} Op={operation.ID}");
                    Close(true);
                }

                operation.RegisterRequest(ServicePoint, this);
                Debug($"WC START: Cnc={ID} Op={operation.ID}");
            }

            operation.Run();
            return(true);
        }