Esempio n. 1
0
 /// <summary>
 /// 线程池线程
 /// </summary>
 /// <param name="threadPool">线程池</param>
 /// <param name="stackSize">堆栈大小</param>
 internal thread(threadPool threadPool, int stackSize)
 {
     this.threadPool           = threadPool;
     threadHandle              = new Thread(run, stackSize);
     threadHandle.IsBackground = true;
     threadHandle.Start();
 }
Esempio n. 2
0
 /// <summary>
 /// 任务处理
 /// </summary>
 /// <param name="count">线程数</param>
 /// <param name="isDisposeWait">默认释放资源是否等待线程结束</param>
 /// <param name="threadPool">线程池</param>
 public task(int count, bool isDisposeWait = true, threadPool threadPool = null)
 {
     if (count <= 0 || count > config.pub.Default.TaskMaxThreadCount)
     {
         fastCSharp.log.Default.Throw(log.exceptionType.IndexOutOfRange);
     }
     maxThreadCount     = count;
     this.isDisposeWait = isDisposeWait;
     this.threadPool    = threadPool ?? fastCSharp.threading.threadPool.Default;
 }
Esempio n. 3
0
 public void Start(threadPool threadPool)
 {
     if (OnError == null)
     {
         threadPool.FastStart(Call, Type);
     }
     else
     {
         threadPool.FastStart(Call, OnError, Type, thread.errorType.Action);
     }
 }
Esempio n. 4
0
 /// <summary>
 /// 任务处理
 /// </summary>
 /// <param name="count">线程数</param>
 /// <param name="isDisposeWait">默认释放资源是否等待线程结束</param>
 /// <param name="threadPool">线程池</param>
 public task(int count, bool isDisposeWait = true, threadPool threadPool = null)
 {
     if (count <= 0 || count > config.pub.Default.TaskMaxThreadCount)
     {
         fastCSharp.log.Error.Throw(log.exceptionType.IndexOutOfRange);
     }
     MaxThreadCount     = count;
     this.isDisposeWait = isDisposeWait;
     this.threadPool    = threadPool ?? fastCSharp.threading.threadPool.TinyPool;
     fastCSharp.domainUnload.Add(this, domainUnload.unloadType.TaskDispose, false);
 }
Esempio n. 5
0
 /// <summary>
 /// 线程池线程
 /// </summary>
 /// <param name="threadPool">线程池</param>
 /// <param name="stackSize">堆栈大小</param>
 /// <param name="task">任务委托</param>
 /// <param name="taskType">任务委托调用类型</param>
 internal thread(threadPool threadPool, int stackSize, object task, callType taskType)
 {
     this.task.Set(task, taskType);
     this.domainUnload.Type    = fastCSharp.domainUnload.unloadType.None;
     this.onErrorType          = errorType.None;
     waitHandle                = new autoWaitHandle(false);
     this.threadPool           = threadPool;
     threadHandle              = new Thread(run, stackSize);
     threadHandle.IsBackground = true;
     threadIndex               = threads.Push(threadHandle);
     threadHandle.Start();
 }
Esempio n. 6
0
 /// <summary>
 /// 线程池线程
 /// </summary>
 /// <param name="threadPool">线程池</param>
 /// <param name="stackSize">堆栈大小</param>
 /// <param name="task">任务委托</param>
 /// <param name="domainUnload">应用程序退出处理</param>
 /// <param name="onError">应用程序退出处理</param>
 /// <param name="taskType">任务委托调用类型</param>
 /// <param name="domainUnloadType">应用程序退出处理调用类型</param>
 /// <param name="onErrorType">应用程序退出处理调用类型</param>
 internal thread(threadPool threadPool, int stackSize, object task, object onError, object domainUnload, callType taskType, errorType onErrorType, domainUnload.unloadType domainUnloadType)
 {
     this.task.Set(task, taskType);
     this.domainUnload.Set(domainUnload, domainUnloadType);
     this.onError              = onError;
     this.onErrorType          = onErrorType;
     waitHandle                = new autoWaitHandle(false);
     this.threadPool           = threadPool;
     threadHandle              = new Thread(run, stackSize);
     threadHandle.IsBackground = true;
     threadIndex               = threads.Push(threadHandle);
     threadHandle.Start();
 }
Esempio n. 7
0
 public void CheckStart(threadPool threadPool)
 {
     if (Type != thread.callType.None)
     {
         if (OnError == null)
         {
             threadPool.FastStart(Call, Type);
         }
         else
         {
             threadPool.FastStart(Call, OnError, Type, thread.errorType.Action);
         }
     }
 }
Esempio n. 8
0
 /// <summary>
 /// 定时任务信息
 /// </summary>
 /// <param name="threadPool">任务处理线程池</param>
 public timerQueue(threadPool threadPool)
 {
     this.threadPool = threadPool ?? threadPool.TinyPool;
     timer.Elapsed  += onTimer;
     timer.AutoReset = false;
 }
Esempio n. 9
0
 /// <summary>
 /// 任务处理
 /// </summary>
 /// <param name="isDisposeWait">默认释放资源是否等待线程结束</param>
 /// <param name="threadPool">线程池</param>
 public taskQueue(bool isDisposeWait = true, threadPool threadPool = null)
 {
     this.isDisposeWait = isDisposeWait;
     this.threadPool    = threadPool ?? fastCSharp.threading.threadPool.TinyPool;
     fastCSharp.domainUnload.Add(this, domainUnload.unloadType.TaskDispose, false);
 }