private void button1_Click(object sender, EventArgs e) { int width, height; UniverseParser.LoadFromFile(); try { width = Convert.ToInt32(textBox1.Text); height = Convert.ToInt32(textBox2.Text); } catch { MessageBox.Show(@"Wrong field value!"); return; } UniverseParser.LoadFromFile(); universe = new Universe(width, height); textBoxOutputManager = new TextBoxOutputManager(universe, richTextBox1, label1); InitConfigs(); universe.GenerateCells(UniverseConsts.DefGenerateCells); textBoxOutputManager.StartSimulation(); isWorking = true; button1.Enabled = false; button2.Enabled = true; button3.Enabled = true; button5.Enabled = true; textBox1.Enabled = false; textBox2.Enabled = false; label1.Text = @""; }
void ChangeConfigs() { string path = Environment.CurrentDirectory + @"\universe_configs.txt"; Process proc = new Process(); proc.StartInfo.FileName = path; proc.Start(); while (!proc.HasExited) { System.Threading.Thread.Sleep(1000); } try { UniverseParser.LoadFromFile(); } catch (Exception e) { MessageBox.Show(e.Message); ChangeConfigs(); return; } // textBoxOutputManager.BeginInvoke(InitConfigs); InitConfigs(); }