/// <summary> /// 创建线程对象 /// </summary> /// <param name="action">线程要执行的委托</param> /// <param name="name">线程名称</param> /// <param name="isBackground">是否后台运行[true:后台线程;false:前台线程]</param> /// <param name="obj">线程启动参数</param> /// <returns>返回线程对象</returns> public static IThreadEx Start(Action <ThreadExPara> action, string name = null, bool isBackground = true, object obj = null) { var thread = new ThreadEx(action, name, isBackground); thread.Start(obj); return(thread); }
private void CreateProcessThread() { if (!this._allowAddThread) { return; } if (!this._allowAddThread) { return; } if (this._isDisposed) { this._allowAddThread = false; return; } if (this._threadList.Count >= Environment.ProcessorCount) { this._allowAddThread = false; return; } if (this._addProcessThreadConditionType) { if (!this._addProcessThreadFunc(this._threadList.Count)) { this._allowAddThread = false; return; } } else { if (this._maxThreadCount > 0 && this._threadList.Count >= this._maxThreadCount) { this._allowAddThread = false; return; } } string threadName = $"{this._threadNamePre}{this._threadList.Count}"; ThreadEx thread = new ThreadEx(this.ProcessThreadMethod, threadName, true); this._threadList.Add(thread); thread.Start(); }