public void RunT <T>(CustomSort <T> customSort, T[] array, Compare <T> CompareByBrandName) { Thread threadStart = new Thread(() => { customSort.Sort(array, CompareByBrandName); }); threadStart.Start(); customSort.SignalEvent.WaitOne(); customSort.SignalEvent.Reset(); }
static void Main(string[] args) { SportCar sportCarOne = new SportCar(460, 15.3, "Porsche"); SportCar sportCarTwo = new SportCar(670, 17.2, "Lamborghini"); SportCar sportCarThree = new SportCar(550, 16.6, "BMW"); var array = new[] { sportCarOne, sportCarTwo, sportCarThree }; CustomSort <SportCar> customSort = new CustomSort <SportCar>(); ShowThread show = new ShowThread(); customSort.SortingFinished += (sender, e) => { Console.WriteLine("Sort finished"); }; show.RunT(customSort, array, CompareByBrandName); }