public MainForm() { InitializeComponent(); grid = new Grid(100, 100); grid.Randomize(); backgroundWorker.WorkerSupportsCancellation = true; comboBox_size.SelectedItem = "100"; DrawArea = new Bitmap(drawBox.Size.Width, drawBox.Size.Height); }
private void button4_Click(object sender, EventArgs e) { if (!backgroundWorker.IsBusy) { this.Invoke((Action)(() => { grid = new Grid(Int32.Parse(comboBox_size.SelectedItem.ToString()), Int32.Parse(comboBox_size.SelectedItem.ToString())); grid.Randomize(); DrawGrid(); })); } }