private void btnStart_Click(object sender, EventArgs e) { System.Threading.Thread.Sleep(10); pictureBox1.Refresh(); pnlPleaseWait.Visible = true; pnlButtons.Visible = false; if (Program.Server == null) { if(txtPhysicalDir.Text.ToLower().Trim().EndsWith(".wap")) { _wap = new WebApplicationPackage(File.Open(txtPhysicalDir.Text, FileMode.Open), true); _wap.Open(); Program.Server = new AsyncServer(System.Net.IPAddress.Any, txtVirtualDir.Text, _wap.PhysicalPath, int.Parse(txtPort.Text)); }else { Program.Server = new AsyncServer(System.Net.IPAddress.Any, txtVirtualDir.Text, txtPhysicalDir.Text, int.Parse(txtPort.Text)); } Program.Server.ServerRunning += OnServerRunning; Program.Server.FailureStarting += OnServerStartFailure; try { Program.Server.StartAsync(); } catch { Program.Server = null; MessageBox.Show("Error starting server, please try again."); } } }
private void CloseWapIfNeeded() { if (_wap != null) { _wap.Dispose(); _wap = null; } }