Пример #1
0
        /// <summary>
        /// Create a TaskScheduler that use <paramref name="concurrentLevel"/> threads to process task concurrently.
        /// </summary>
        /// <param name="concurrentLevel">concurrent level</param>
        /// <param name="threadName">name of thread</param>
        /// <returns>a DedicatedTaskScheduler instance</returns>
        /// <exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="concurrentLevel"/> argument is less than 1.</exception>
        public static TaskScheduler MultiThread(int concurrentLevel = 1, string threadName = MultiThreadName)
        {
            if (concurrentLevel < 1)
            {
                throw new ArgumentOutOfRangeException(nameof(concurrentLevel));
            }
            var taskScheduler = new DedicatedTaskScheduler(threadName, concurrentLevel);

            return(taskScheduler);
        }
Пример #2
0
        /// <summary>
        /// Create a TaskScheduler that use only one thread to process task.
        /// </summary>
        /// <param name="threadName">name of thread</param>
        /// <returns>a DedicatedTaskScheduler instance</returns>
        public static TaskScheduler SingleThread(string threadName = SingleThreadName)
        {
            var taskScheduler = new DedicatedTaskScheduler(threadName);

            return(taskScheduler);
        }