public void DisconnectData(int topic) { Trace.WriteLineIf(traceSwitch.TraceInfo, "Disconnecting topic: " + topic); lock (this) { foreach (DictionaryEntry de in cache) { RTDData data = (RTDData)de.Value; if (data.containsTopic(topic)) { data.removeTopic(topic); } if (data.getTopics().Length == 0) { cache.Remove(de.Key); } } } timer.Stop(); timer.Start(); }
public Array RefreshData(ref int TopicCount) { Trace.WriteLineIf(traceSwitch.TraceInfo, "RefreshData"); lock (this) { int numItems = 0; foreach (DictionaryEntry de in cache) { RTDData item = (RTDData)de.Value; if (item.Updated) { numItems += item.getTopics().Length; } } object[,] ret = new object[2, numItems]; int i = 0; try { foreach (DictionaryEntry de in cache) { RTDData item = (RTDData)de.Value; if (item.Updated) { int [] topics = item.getTopics(); for (int j = 0; j < topics.Length; j++) { ret[0, i] = topics[j]; ret[1, i] = item.getVal(topics[j]); i++; } } } } catch (Exception e) { Debug.WriteLine(e.ToString()); } TopicCount = i; Trace.Flush(); return(ret); } }