Exemple #1
0
        /// <summary>
        /// Creates new thread and sorts an array in this thread.
        /// </summary>
        /// <typeparam name="T">Type of elements in array to sort.</typeparam>
        /// <param name="array">Array to sort.</param>
        /// <param name="comparator">Comparator providing a method for
        /// comparing two items.</param>
        public void SortInAdditionalThread <T>(T[] array, Func <T, T, bool> comparator)
        {
            int threadId = ++_threadID;

            new Thread(() => {
                SortArray(array, comparator);
                OnSortIsFinished?.Invoke($"Sorting is finished in Thread with ID {threadId}.");
            }).Start();
        }
Exemple #2
0
 public static void SortArrayInNewThread <T>(T[] array, Func <T, T, bool> comparePredicate)
 {
     new Thread(() =>
     {
         ArraySort(array, comparePredicate);
         OnSortIsFinished?.Invoke($"Sorting is finished. Thread hashcode: {Thread.CurrentThread.GetHashCode()} ");
     }).Start();
     Thread.Sleep(300);
 }