private void bgw_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker bw = sender as BackgroundWorker; string SortEngineName = (string)e.Argument; Type type = Type.GetType("SortVisualizer." + SortEngineName); var ctors = type.GetConstructors(); //try //{ ISortEngine se = (ISortEngine)ctors[0].Invoke(new object[] { theArray, g, panel1.Height }); while (!se.IsSorted()) { se.NextStep(); } //} catch (Exception ex) //{ //} }
public void bgw_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { BackgroundWorker bw = sender as BackgroundWorker; string SortEngineName = (string)e.Argument; Type type = Type.GetType("SortVisualizer." + SortEngineName); var ctors = type.GetConstructors(); try { ISortEngine se = (ISortEngine)ctors[0].Invoke(new object[] { TheArray, g, panel1.Height }); while (!se.IsSorted() && (!bgw.CancellationPending)) { se.NextStep(); } } catch (Exception ex) { } }