public void SetThreadShareParam(int workId, ThreadGroup threadGroup, EudiSynchronizationType syncType = EudiSynchronizationType.Unity) { if (threadGroup.UseDefaultTasks) { var firstCreation = false; WorkerTask task = null; if (!threadGroup.Tasks.TryGetValue(workId, out task)) { task = EudiThreading.CreateTask(); task.TaskId = workId; threadGroup.Tasks[workId] = task; firstCreation = true; } if (task != null) { task.SynchronizationType = syncType; OnNewWorkerTask(task, firstCreation); m_threadGroups.Add(threadGroup); task.Workers.Add(this); m_workerTasks.Add(task); } } else { threadGroup.CreateFromWorker(this, workId, syncType); m_threadGroups.Add(threadGroup); } }
public void Destroy() { var cleanFields = WorkerOnDestroy(); parent = null; // No need to perform this if we are ending the application, the initiatorEngine is already removing that for us if (!Eudi.ApplicationIsEnding) { foreach (var workerTask in m_workerTasks) { workerTask.Workers.Remove(this); if (workerTask.Workers.Count == 0) { var group = m_threadGroups[workerTask.TaskId]; EudiThreading.RemoveThreadGroup(group, group.MetaCreationType, group.MetaCreationGroupId); } } } m_threadGroups.Clear(); m_threadGroups = null; m_workerTasks.Clear(); m_workerTasks = null; if (!cleanFields) { var type = GetType(); var fields = type.GetFields(); var fieldsCount = fields.Length; for (int i = 0; i < fieldsCount; i++) { var field = fields[i]; field.SetValue(this, null); } } }