Esempio n. 1
0
 public static void CustomSortStringDemo()
 {
     string[] StringArray = new string[]
     {
         "afg", "uydd", "fjsfgfg", "adddd", "jddgfg", "bag", "lklolkl"
     };
     SortHandler.SortArray(StringArray, (a, b) => (!SortHandler.CompareString(a, b)));
 }
Esempio n. 2
0
        public static void SortArrayInThread()
        {
            OnSort += SortEventHandler;


            new Thread(() =>
            {
                int length     = 15;
                Random rnd     = new Random();
                int[] IntArray = new int[length];
                for (int i = 0; i < IntArray.Length; i++)
                {
                    IntArray[i] = rnd.Next(0, 100);
                }
                Thread.Sleep(5000);
                SortHandler.SortArray(IntArray, (a, b) => a > b);
                OnSort?.Invoke("\nSorting is complete INT\n");
            }).Start();
            new Thread(() =>
            {
                int length           = 15;
                Random rnd           = new Random();
                double[] DoubleArray = new double[length];
                for (int i = 0; i < DoubleArray.Length; i++)
                {
                    DoubleArray[i] = rnd.NextDouble() * 100;
                }
                Thread.Sleep(5000);
                SortHandler.SortArray(DoubleArray, (a, b) => a > b);
                OnSort?.Invoke("\nSorting is complete DOUBLE\n");
            }).Start();
            new Thread(() =>
            {
                string[] StringArray = new string[]
                {
                    "afg", "uydd", "fjsfgfg", "adddd", "jddgfg", "bag", "lklolkl"
                };
                Thread.Sleep(5000);
                SortHandler.SortArray(StringArray, (a, b) => (!SortHandler.CompareString(a, b)));
                OnSort?.Invoke("\nSorting is complete STRING\n");
            }).Start();
            new Thread(() =>
            {
                while (_threadCount != 3)
                {
                    Thread.Sleep(500);
                    Console.WriteLine("Sorting...");
                }
                ;
            }).Start();
        }