示例#1
0
 internal void RemoveConnection(HttpConnection cnc)
 {
     _connections.Remove(cnc);
 }
示例#2
0
        void Cleanup(bool closeExisting)
        {
            lock (_registry)
            {
                if (closeExisting)
                {
                    // Need to copy this since closing will call UnregisterContext
                    var keys = _registry.Keys;
                    var all = new HttpListenerContext[keys.Count];
                    keys.CopyTo(all, 0);
                    _registry.Clear();
                    for (var i = all.Length - 1; i >= 0; i--)
                        all[i].Connection.Close(true);
                }

                lock (_connections.SyncRoot)
                {
                    var keys = _connections.Keys;
                    var conns = new HttpConnection[keys.Count];
                    keys.CopyTo(conns, 0);
                    _connections.Clear();
                    for (var i = conns.Length - 1; i >= 0; i--)
                        conns[i].Close(true);
                }
                lock (_ctxQueue)
                {
                    var ctxs = (HttpListenerContext[])_ctxQueue.ToArray(typeof(HttpListenerContext));
                    _ctxQueue.Clear();
                    for (var i = ctxs.Length - 1; i >= 0; i--)
                        ctxs[i].Connection.Close(true);
                }

                lock (_waitQueue)
                {
                    Exception exc = new ObjectDisposedException("listener");
                    foreach (ListenerAsyncResult ares in _waitQueue)
                    {
                        ares.Complete(exc);
                    }
                    _waitQueue.Clear();
                }
            }
        }
示例#3
0
 internal void AddConnection(HttpConnection cnc)
 {
     _connections[cnc] = cnc;
 }
示例#4
0
 internal HttpListenerContext(HttpConnection cnc)
 {
     Connection = cnc;
     Request = new HttpListenerRequest(this);
     Response = new HttpListenerResponse(this);
 }
示例#5
0
 internal void RemoveConnection(HttpConnection cnc) => _connections.TryRemove(cnc, out _);
示例#6
0
 internal void AddConnection(HttpConnection cnc) => _connections[cnc] = cnc;
示例#7
0
 internal void RemoveConnection(HttpConnection cnc)
 {
     _connections.Remove(cnc);
 }