private void _UpdateIndex(ICollectionIndexer indexer) { ThreadPool.QueueUserWorkItem (delegate { Debug ("Running indexer"); try { UpdateIndex (indexer); } catch (Exception e) { Console.Error.WriteLine (e); } Debug ("Indexer finished"); indexer.Dispose (); if (!ApplicationAvailable || !listening) { DisconnectFromIndexerService (); } }); }
protected override void UpdateIndex(ICollectionIndexer indexer) { lock (shutdown_mutex) { indexer_running = true; shutdown_requested = false; } bool shutdown_while_indexing = false; if (parent.export_fields != null && parent.export_fields.Count > 0) { indexer.SetExportFields (parent.export_fields.ToArray ()); } parent.OnBeginUpdateIndex (); for (int i = 0, models = indexer.GetModelCounts (); i < models; i++) { for (int j = 0, items = indexer.GetModelResultsCount (i); j < items; j++) { if (Shutdown) { shutdown_while_indexing = true; break; } parent.IndexResult (indexer.GetResult (i, j)); } if (shutdown_while_indexing) { break; } } lock (shutdown_mutex) { indexer_running = false; shutdown_requested = false; } if (shutdown_while_indexing) { parent.OnShutdownWhileIndexing (); } parent.OnEndUpdateIndex (); }
protected abstract void UpdateIndex(ICollectionIndexer indexer);