private static long GetWorkHashCode(LuceneWorker.WorkWithPayload luceneWork) { IDirectoryProvider provider = luceneWork.Provider; int h = provider.GetType().GetHashCode(); h = (31 * h) + provider.GetHashCode(); long extendedHash = h; // to be sure extendedHash + 1 < extendedHash + 2 is always true if (luceneWork.Work is AddLuceneWork) { extendedHash += 1; // addwork after deleteWork } if (luceneWork.Work is OptimizeLuceneWork) { extendedHash += 2; // optimize after everything } return(extendedHash); }