title: Multi-threaded HttpListener with await async and Tasks
body: <p>Would this be a good example of a scalable HttpListener that is multi-threaded?</p>
  
  <p>Is this how for example a real IIS would do it?</p>
  
  <pre><code>public class Program
  {
      private static readonly HttpListener Listener = new HttpListener();
  
      public static void Main()
      {
          Listener.Prefixes.Add("http://+:80/");
          Listener.Start();
          Listen();
          Console.WriteLine("Listening...");
          Console.WriteLine("Press any key to exit...");
          Console.ReadKey();
      }
  
      private static async void Listen()
      {
          while (true)
          {
              var context = await Listener.GetContextAsync();
              Console.WriteLine("Client connected");
              Task.Factory.StartNew(() =&gt; ProcessRequest(context));
          }
  
          Listener.Close();
      }
  
      private static void ProcessRequest(HttpListenerContext context)
      {
          System.Threading.Thread.Sleep(10*1000);
          Console.WriteLine("Response");
      }
  }
  </code></pre>
  
  <p>I'm specifically looking for a scalable solution that DOES NOT rely on IIS. Instead only on http.sys (which is the httplistener class) -- The reason for not relying on iIS is because the govt. area I work in requires extremely reduced surface area of attack.</p>