Beispiel #1
0
        private void ListenForRequests()
        {
            Console.WriteLine($"Listening... {_HttpListener.Prefixes.FirstOrDefault()}");

            while (Connected)
            {
                var contextTask = _HttpListener.GetContextAsync();
                Task.WaitAll(new Task[] { contextTask }, _ConnectionCancellationToken.Token);

                if (!_ConnectionCancellationToken.IsCancellationRequested)
                {
                    _ConnectionHandler.HandleListenerContext(contextTask.Result);
                }
            }

            Console.WriteLine($"Stopped listening to {_HttpListener.Prefixes.FirstOrDefault()}");
        }