The exception is thrown up at times saying the file write.lock
cannot be used as it is being used by another process, however this is a very simple test app for Lucene.Net and there's no other process using it, any idea of how this may be
The exception details are as follows:
System.IO.IOException was unhandled
HResult=-2147024864
Message=The process cannot access the file
'c:\temp\luceneidx\write.lock' because it is being used by another process.
Source=mscorlib
StackTrace:
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.File.InternalDelete(String path, Boolean checkHost)
at System.IO.File.Delete(String path)
at Lucene.Test.LuceneSearchInternal.get__directory()
in C:\Lucene.Test\LuceneSearchResumes.cs:line 35
The relevant code throwing the exception is,
var lockFilePath = Path.Combine(_luceneDir, "write.lock");
if (File.Exists(lockFilePath))
File.Delete(lockFilePath); // THROWS exception sometimes
The code is mostly from this article.
The index is being built on a background thread using Task.Factory.StartNew()
and the WPF GUI does a search while the index is being built. There's only one thread writing documents to the index.
Question: Which other process is using the Lucene.Net index?