private bool GetItem(ItemValueResult[] values, int index, out ManagedItem res) { if (itemIndex.TryGetValue(values[index].ClientHandle.ToString(), out res)) { return(true); } else if (values.Length == managedItems.Length) { res = managedItems[index]; return(true); } return(false); }
public ItemResult[] AddItem(Item[] items, string[] queries) { managedItems = new ManagedItem[items.Length]; itemIndex = new ConcurrentDictionary <string, ManagedItem>(); for (int i = 0; i < items.Length; i++) { if (items[i].ClientHandle == null || itemIndex.ContainsKey(items[i].ClientHandle.ToString())) { items[i].ClientHandle = String.Format("0x{0:X3}", i + 1); } ManagedItem managedItem = new ManagedItem(new Item(items[i]), queries[i], Buffered, minuteFilter); itemIndex.TryAdd(managedItem.item.ClientHandle.ToString(), managedItems[i] = managedItem); } ItemResult[] res = innerSubscription.AddItems(items); if (minuteFilter) { SetAckTimestamp(); timer = new Timer(new TimerCallback(Acknowledgment), null, 250, 0); } return(res); }