private void btnRecalc_Click(object sender, EventArgs e) { if (btnRecalc.Enabled) { btnRecalc.Enabled = false; try { double channel = Decimal.ToDouble(channelWide.Value); t = new Timer(); t.Tick += new EventHandler(t_Tick); t.Interval = 100; t.Start(); pc = new ParcourGenerator(); lock (activeParcour) { pc.RecalcParcour(activeParcour, c, channel); } PictureBox1.Invalidate(); } catch (Exception ex) { btnRecalc.Enabled = true; MessageBox.Show(ex.Message, "Error while generating Parcour"); } } }