private void GetDataThread(object data) { CThreadData d = data as CThreadData; if (d != null) { IWndIncluableDansDataGrid ctrl = null; if (m_dicControles.TryGetValue(d.ColumnIndex, out ctrl)) { CCoupleValeurEtValeurDisplay dTmp = GetValeurHorsCache(d.Objet, d.ColumnIndex, d.Cache); m_grid.OnDataArrivé(d.Objet, d.ColumnIndex); } } }
public CCoupleValeurEtValeurDisplay GetValeur(object objet, int nColonne, bool bMultiThread) { if (objet == null) { return(new CCoupleValeurEtValeurDisplay("", null)); } CObjetDataCache cache = null; try { if (!m_cache.TryGetValue(objet, out cache)) { cache = new CObjetDataCache(objet); m_cache[objet] = cache; } } finally { if (cache == null) { cache = new CObjetDataCache(objet); m_cache[objet] = cache; } } CCoupleValeurEtValeurDisplay data = cache.GetValeur(nColonne); if (data != null) { return(data); } if (bMultiThread) { cache.SetValeur(nColonne, c_strWaitingData, null); CThreadData thread = new CThreadData(objet, nColonne, cache); lock (typeof(CLockThread)) { m_listeThreadToStart.Add(thread); } return(new CCoupleValeurEtValeurDisplay(c_strWaitingData, null)); } else { data = GetValeurHorsCache(objet, nColonne, cache); return(data); } }
private void StartThreadTask(object state) { if (m_bInStartThreadTask) { return; } m_bInStartThreadTask = true; try { lock (typeof(CLockThread)) { IEnumerable <Thread> threads = from t in m_listeThreadStarted where t.ThreadState != ThreadState.Running select t; foreach (Thread thToDelete in threads.ToArray()) { m_listeThreadStarted.Remove(thToDelete); } if (m_listeThreadToStart.Count == 0) { return; } while (m_listeThreadToStart.Count > 0 && m_listeThreadStarted.Count < c_nMaxThread) { CThreadData data = m_listeThreadToStart[0]; m_listeThreadToStart.RemoveAt(0); Thread th = new Thread(GetDataThread); th.Priority = ThreadPriority.BelowNormal; m_listeThreadStarted.Add(th); th.Start(data); } } } finally { m_bInStartThreadTask = false; } }