Exemplo n.º 1
0
 public static ThreadPoolManager getInstance()
 {
     if (threadPoolManager == null)
     {
         threadPoolManager = new ThreadPoolManager(1, 5, 1);
     }
     return(threadPoolManager);
 }
Exemplo n.º 2
0
        /// <summary>
        /// 获取实例
        /// </summary>
        /// <param name="min">初始化最小线程数</param>
        /// <param name="max">初始化最大线程数</param>
        /// <param name="increment">线程增量数</param>
        /// <returns></returns>
        public static ThreadPoolManager getInstance(int min, int max, int increment)
        {
            if (threadPoolManager == null)
            {
                threadPoolManager = new ThreadPoolManager(min, max, increment);
            }

            return(threadPoolManager);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Completes the Task before returning.
        /// If the task has been canceled a TaskCanceledException is thrown.
        /// </summary>
        public void Complete()
        {
            if (MyPromise.Canceled.Value)
            {
                throw new TaskCanceledException("Task was canceled.");
            }
            else
            {
                while (!MyPromise.Complete.Value)
                {
                    ThreadPoolManager.ExecuteSingleTask();
                }

                if (MyPromise.CaughtException != null)
                {
                    throw MyPromise.CaughtException;
                }
            }
        }