private static HttpServer StartHttpServer() { var httpServer = new HttpServer(); httpServer.ReceiveWebRequest += ProcessHttpRequest; httpServer.Start(SERVER_URL); return httpServer; }
private void HandleFormClosing(object sender, FormClosingEventArgs e) { if (httpServer != null) { httpServer.Stop(); httpServer = null; } if (client != null) { client.CancelAsync(); } }
private void HandleDownloadZipButtonClick(object sender, EventArgs e) { if (httpServer == null || !httpServer.IsStarted) { httpServer = StartHttpServer(); pictureBoxServerStatus.Image = imageListIcons.Images["server-started"]; linkLabelServer.Text = SERVER_URL; linkLabelServer.Visible = true; } if (client != null) return; client = new WebClient(); client.DownloadDataCompleted += DownloadDataCompleted; client.DownloadProgressChanged += DownloadProgressChanged; client.DownloadDataAsync(new Uri(SERVER_URL + "random.zip")); }