private void buttonStart_Click(object sender, EventArgs e) { fatimaServer?.Close(); if (serverThread != null) { serverThread.Abort(); } try { serverThread = new Thread(new ThreadStart(this.ServerThread)); serverThread.Start(); } catch (Exception ex) { this.textBoxServer.Text = ex.Message; serverThread = null; } }
private void ServerThread() { try { fatimaServer?.Close(); fatimaServer = new HTTPFAtiMAServer() { IatFilePath = iat._currentScenarioFilePath, AssetFilePath = iat.textBoxPathAssetStorage.Text, Port = int.Parse(this.textBoxPort.Text) }; fatimaServer.OnServerEvent += ServerNotificationHandler; fatimaServer.Run(); } catch (Exception ex) { this.Invoke(this.updateUIDelegate, new string[] { "Error while loading the assets!", UIELEMENT_SERVERSTATUS, "Red" }); fatimaServer?.Close(); return; } }