int AddIterator(ResourceIterator iterator) { int id = Interlocked.Increment(ref iteratorId); return(iterators.TryAdd(id, iterator) ? id : -1); }