private static async Task MainAsync(string[] args) { Process php = new Process(); php.StartInfo.FileName = appdata + @"php\php.exe"; if (File.Exists(appdata + "Web\\ip.txt")) { php.StartInfo.Arguments = "-S 0.0.0.0:8080 -t \"" + appdata + "Web\""; } else { php.StartInfo.Arguments = "-S 127.0.0.1:8080 -t \"" + appdata + "Web\""; } php.Start(); var tcs = new TaskCompletionSource <object>(); var server = new AsyncHttpServer(portNumber: 8080); //var task = Task.Run(() => server.Start()); await Console.Out.WriteLineAsync("Listening on port 8080"); checkDriver("VID_1781&PID_0C9F"); //checkDriver("VID_16C0&PID_05DC"); await tcs.Task; await server.Stop(); }
static void Main(string[] args) { var server = new AsyncHttpServer(portNumber: 1234); var t = Task.Run(() => server.Start()); Console.WriteLine("Listening on port 1234. Open http://localhost:1234 in your browser."); Console.WriteLine("Trying to connect:"); Console.WriteLine(); GetResponseAsync("http://localhost:1234").GetAwaiter().GetResult(); Console.WriteLine(); Console.WriteLine("Press Enter to stop the server."); Console.ReadLine(); server.Stop().GetAwaiter().GetResult(); }
static void Main(string[] args) { var server = new AsyncHttpServer(1234); var t = Task.Run(() => server.Start()); WriteLine("Listening on port 1234. Open http://localhost:1234 in your browser."); WriteLine("Trying to connect:"); WriteLine(); GetResponseAsync("http://localhost:1234").GetAwaiter().GetResult(); WriteLine(); WriteLine("Press Enter to stop the server."); ReadLine(); server.Stop().GetAwaiter().GetResult(); }
public override void Run() { var server = new AsyncHttpServer(1234); var t = Task.Run(() => server.Start()); Console.WriteLine("Listening on port 1234. http://localhost:1234 in your browser."); Console.WriteLine("Trying to connect:"); Console.WriteLine(); GetResponseAsync("http://localhost:1234").GetAwaiter().GetResult(); Console.WriteLine(); Console.WriteLine("Press Enter to stop the server."); Console.ReadLine(); server.Stop().GetAwaiter().GetResult(); }
public void TearDown() { server.Stop(); }
public void Stop() { server.Stop(); server.Dispose(); }