public void Start(AppFunc app) { if (1 != Interlocked.Increment(ref _started)) throw new InvalidOperationException("Server is already started."); _app = app; _listener.Start(); _listener.BeginAcceptSocket(Callback, null); }
static void Main(string[] args) { using (var server = new Server(8080)) { server.Start(WebApp.App(new GmcJobList())); Console.WriteLine("Running server"); Console.WriteLine("Press enter to exit"); Console.ReadLine(); server.Stop(); } }