private void MainForm_FormClosed(object sender, FormClosedEventArgs e) { if ((bool)thread?.IsAlive) { thread.Abort(); } sort.bmp.Dispose(); sort = null; }
public MainForm() { InitializeComponent(); this.FormBorderStyle = FormBorderStyle.FixedSingle; masN = 20; sort = new VisualiseSort(PictureBox, masN, delay); sort.DrawMas(); thread = new Thread(new ThreadStart(Start)); timer1.Tick += new EventHandler(Update); timer1.Interval = delay; timer1.Start(); }