Ejemplo n.º 1
0
        /// <summary>
        /// Closes the StartListenerAsync.
        /// </summary>
        public void Close()
        {
            if (_cts == null)
            {
                //Don't throw exception in this case, just ignore it :)
                return; //throw new InvalidOperationException("HttpListener is not running.");
            }

            Request = null;

            _cts.Cancel();
            _cts = null;

            _isListening = false;
            _tcpListener.Stop();

            try
            {
                // Stop task
                _listener.Wait(TimeSpan.FromMilliseconds(1));
            }
            catch (Exception)
            {
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Closes the listener.
        /// </summary>
        public void Close()
        {
            if (_cts == null)
            {
                throw new InvalidOperationException("HttpListener is not running.");
            }

            Request = null;
            _cts.Cancel();
            _cts         = null;
            _isListening = false;
            _tcpListener.Stop();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Closes the StartListenerAsync.
        /// </summary>
        public void Close()
        {
            if (_cts == null)
            {
                throw new InvalidOperationException("HttpListener is not running.");
            }

            _cts.Cancel();
            _cts = null;

            _isListening = false;
            _tcpListener.Stop();

            try
            {
                // Stop task
                _listener.Wait(TimeSpan.FromMilliseconds(1));
            }
            catch (Exception)
            {
            }
        }