Пример #1
0
        //builds and starts a sorting thread of the given sorting type.
        private void sort(Sorts the_sort)
        {
            //removes the old sorting thread if present
            if (my_drawable != null)
            {
                resetOldThread();
            }

            //gets the maximum input value from the user
            int max = getMax();

            if (max == -1)
            {
                return;
            }

            //setup new sorting thread
            my_drawable = new DrawnSort(the_sort, getInputArray(max), pnlDraw.Width, pnlDraw.Height, max, drawPanel, this);

            //make sure old memory is reclaimed (otherwise a leak can occur)
            GC.Collect();
            GC.WaitForPendingFinalizers();

            //start the sorting thread
            my_drawable.start();
        }