public Thread(ParameterizedThreadStart task, object obj, int size) { this.size = size; runnable1 = task; param = obj; MakeThis(true); }
/// <summary></summary> public virtual void StartGameThread() { var threadStart = new System.Threading.ParameterizedThreadStart(App.PluginLoop); GameThread = new System.Threading.Thread(threadStart); GameThread.Start(App.BatchFile.PluginArgs); }
public static System.Threading.Thread StartThread(System.Threading.ParameterizedThreadStart start, object obj, bool isBackground) { System.Threading.Thread thread = new System.Threading.Thread(start); thread.IsBackground = isBackground; thread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); thread.Start(obj); return(thread); }
public static void AddThread(System.Threading.ParameterizedThreadStart targetMethod) { Thread th = new Thread(targetMethod); threadList.Add(th); th.IsBackground = true; th.Start(); }
public void RunMoreSave(object ob) { lock (this) { if (State != 1) { State = 1; StartTime = DateTime.Now; System.Threading.ParameterizedThreadStart ts = new System.Threading.ParameterizedThreadStart(MoreExport); Thread thread = new Thread(ts); thread.Start(ob); } } }
public void Init() { //string host = "127.0.0.1"; // port = "6000"; ds = dsHandle.GetDataSet(@"Extractvalue(通讯参数, '/root/ip') As 仪器IP, Extractvalue(通讯参数, '/root/port') As 端口, Extractvalue(通讯参数, '/root/role') As 接收角色, Extractvalue(通讯参数, '/root/host') As 主机IP", "检验仪器", "id = '" + strInstrumentID + "'"); ip = ds.Tables[0].Rows[0]["仪器IP"].ToString(); port = ds.Tables[0].Rows[0]["端口"].ToString(); role = ds.Tables[0].Rows[0]["接收角色"].ToString(); host_ip = ds.Tables[0].Rows[0]["主机IP"].ToString(); role = role == "" ? "S" : (role.Replace("1", "S").Replace("2", "C")); ds = dsHandle.GetDataSet(@"解析类型,通讯程序名,名称,备注,Extractvalue(接收规则, '/root/data_type') As data_type, Extractvalue(接收规则, '/root/data_begin') As data_begin, Extractvalue(接收规则, '/root/data_end') As data_end, Extractvalue(接收规则, '/root/start_cmd') As start_cmd, Extractvalue(接收规则, '/root/end_cmd') As end_cmd, Extractvalue(接收规则, '/root/ack_all') As ack_all, Extractvalue(接收规则, '/root/ack_term') As ack_term, Extractvalue(接收规则, '/root/decode_mode') As decode_mode, Extractvalue(接收规则, '/root/begin_bits') As begin_bits, Extractvalue(接收规则, '/root/end_bits') As end_bits", "检验仪器", "id = '" + strInstrumentID + "'"); dataType = ds.Tables[0].Rows[0]["data_type"].ToString(); databegin = ds.Tables[0].Rows[0]["data_begin"].ToString(); dataend = ds.Tables[0].Rows[0]["data_end"].ToString(); //inBegin = ds.Tables[0].Rows[0][3].ToString(); //inEnd = ds.Tables[0].Rows[0][4].ToString(); decode_mode = ds.Tables[0].Rows[0]["decode_mode"].ToString(); SubBegin = ds.Tables[0].Rows[0]["begin_bits"].ToString(); SubEnd = ds.Tables[0].Rows[0]["end_bits"].ToString(); ACK_term = ds.Tables[0].Rows[0]["ack_term"].ToString(); ACK_all = ds.Tables[0].Rows[0]["ack_all"].ToString(); CommProgramName = ds.Tables[0].Rows[0]["通讯程序名"].ToString(); strDeviceName = ds.Tables[0].Rows[0]["名称"].ToString(); RemarkContent = ds.Tables[0].Rows[0]["备注"].ToString(); try { obj = ObjectReflection.CreateObject(CommProgramName.Substring(0, CommProgramName.IndexOf(".dll"))); IResolve = obj as IDataResolve; IResolve.GetRules(strInstrumentID); } catch (Exception exobj) { writeLog.Write(strDeviceName, exobj.Message, "log"); return; } //通过线程去提取数据 System.Threading.ParameterizedThreadStart ParStart = new System.Threading.ParameterizedThreadStart(Start); System.Threading.Thread threadSocket = new System.Threading.Thread(ParStart); object socketListen = strError; threadSocket.Start(socketListen); //Start(); }
public static CoRProcessThreadState[] CalculateCenterOfRotation(this RenderChunk chunk, int maxThreadNumber, float similarityKernel, float similarityThreshold) { if (chunk.clusterArray == null || chunk.clusteredVertexIndexArray == null) { Debug.LogError("Must need pre-calculated Center Of Clusters"); return(null); } CoRProcessThreadState[] processStateArray = new CoRProcessThreadState[maxThreadNumber]; chunk.centerOfRotationPositionArray = new Vector3[chunk.vertexCount]; System.Threading.ParameterizedThreadStart CoRProcessStart = (threadObj) => { Thread thread = threadObj as Thread; Match match = Regex.Match(thread.Name, threadNameRegexPattern); int currentThreadNum = int.Parse(match.Groups[1].Value), maximumThreadNum = int.Parse(match.Groups[2].Value), vertexLegnth = chunk.vertexCount; try { for (int clusterIndex = currentThreadNum; clusterIndex < chunk.clusterArray.Length; clusterIndex += maximumThreadNum) { ClusterData currentCluster = chunk.clusterArray[clusterIndex]; for (int clusterVertexIndex = currentCluster.startIndexOfCluster; clusterVertexIndex < currentCluster.startIndexOfCluster + currentCluster.lengthOfCluster; clusterVertexIndex++) { int vertexIndex = chunk.clusteredVertexIndexArray[clusterVertexIndex]; Vector3 calculatedVertex = Vector3.zero; float sumedSimiliarity = 0f; for (int clusterTriangleIndex = currentCluster.startIndexOfTriangles; clusterTriangleIndex < currentCluster.startIndexOfTriangles + currentCluster.lengthOfTriangles; clusterTriangleIndex++) { int triangleIndex = chunk.clusteredTriangleIndexArray[clusterTriangleIndex]; float similarity = chunk.GetSimliarity( vertexIndex, chunk.indices[triangleIndex * 3 + 0], chunk.indices[triangleIndex * 3 + 1], chunk.indices[triangleIndex * 3 + 2], similarityKernel ); if (similarity < similarityThreshold) { continue; } float area = chunk.GetArea( chunk.indices[triangleIndex * 3 + 0], chunk.indices[triangleIndex * 3 + 1], chunk.indices[triangleIndex * 3 + 2] ); calculatedVertex += (Vector3)( chunk.dataPerVertex[chunk.indices[triangleIndex * 3 + 0]].position + chunk.dataPerVertex[chunk.indices[triangleIndex * 3 + 1]].position + chunk.dataPerVertex[chunk.indices[triangleIndex * 3 + 2]].position ) / 3 * area * similarity; sumedSimiliarity += area * similarity; } if (sumedSimiliarity > 0) { chunk.centerOfRotationPositionArray[vertexIndex] = calculatedVertex / sumedSimiliarity; } else { chunk.centerOfRotationPositionArray[vertexIndex] = chunk.dataPerVertex[vertexIndex].position; processStateArray[currentThreadNum].emptyCount++; } processStateArray[currentThreadNum].processCount++; } } processStateArray[currentThreadNum].done = true; } catch (Exception e) { Debug.LogError(e); Debug.LogError(e.Source); Debug.LogError(e.Message); processStateArray[currentThreadNum].fail = true; } }; for (int i = 0; i < maxThreadNumber; i++) { Thread thread = new Thread(CoRProcessStart); thread.Name = String.Format(threadNameFormat, i, maxThreadNumber); thread.Start(thread); } return(processStateArray); }
private static void ThreadedScale(Texture2D tex, int newWidth, int newHeight, bool useBilinear) { texColors = tex.GetPixels(); newColors = new Color[newWidth * newHeight]; if (useBilinear) { ratioX = 1.0f / ((float)newWidth / (tex.width - 1)); ratioY = 1.0f / ((float)newHeight / (tex.height - 1)); } else { ratioX = ((float)tex.width) / newWidth; ratioY = ((float)tex.height) / newHeight; } w = tex.width; w2 = newWidth; var cores = Mathf.Min(SystemInfo.processorCount, newHeight); var slice = newHeight / cores; finishCount = 0; if (mutex == null) { mutex = new Mutex(false); } if (cores > 1) { int i = 0; ThreadData threadData; for (i = 0; i < cores - 1; i++) { threadData = new ThreadData(slice * i, slice * (i + 1)); System.Threading.ParameterizedThreadStart ts = useBilinear ? new ParameterizedThreadStart(BilinearScale) : new ParameterizedThreadStart(PointScale); Thread thread = new Thread(ts); thread.Start(threadData); } threadData = new ThreadData(slice * i, newHeight); if (useBilinear) { BilinearScale(threadData); } else { PointScale(threadData); } while (finishCount < cores) { Thread.Sleep(1); } } else { ThreadData threadData = new ThreadData(0, newHeight); if (useBilinear) { BilinearScale(threadData); } else { PointScale(threadData); } } tex.Resize(newWidth, newHeight); tex.SetPixels(newColors); tex.Apply(); texColors = null; newColors = null; }
public Thread(st.ParameterizedThreadStart start, object param) { ThreadID = Cosmos.HAL.Global.SpawnThread(start, param); ThreadFinalSetup(); }
public Thread(ParameterizedThreadStart task, object obj) { runnable1 = task; param = obj; MakeThis(true); }