Lucene.Net.Index.IndexReader.IncRef C# (CSharp) Method

IncRef() public method

Expert: increments the refCount of this IndexReader instance. RefCounts are used to determine when a reader can be closed safely, i.e. as soon as there are no more references. Be sure to always call a corresponding DecRef, in a finally clause; otherwise the reader may never be closed. Note that Close simply calls decRef(), which means that the IndexReader will not really be closed until DecRef has been called for all outstanding references.
public IncRef ( ) : void
return void
		public virtual void  IncRef()
		{
			lock (this)
			{
				System.Diagnostics.Debug.Assert(refCount > 0);
				EnsureOpen();
				refCount++;
			}
		}
		

Usage Example

Example #1
0
        public virtual void  TestLucene1516Bug()
        {
            Directory dir1 = new MockRAMDirectory();

            TestIndexReaderReopen.CreateIndex(dir1, false);
            IndexReader r1 = IndexReader.Open(dir1, false);

            r1.IncRef();
            IndexReader r2 = r1.Clone(false);

            r1.DeleteDocument(5);
            r1.DecRef();

            r1.IncRef();

            r2.Close();
            r1.DecRef();
            r1.Close();
            dir1.Close();
        }
All Usage Examples Of Lucene.Net.Index.IndexReader::IncRef