Exemplo n.º 1
0
        private void ValidateIndex(bool force)
        {
            //Index = null;
            var sln     = GetService(typeof(SVsSolution)) as IVsSolution;
            var slnName = SolutionIndex.GetSlnFileName(sln);

            if (slnName == null)
            {
                Index = null;
                return;
            }

            if (Index == null || !Index.SolutionName.Equals(slnName, StringComparison.OrdinalIgnoreCase))
            {
                Index             = new SolutionIndex(slnName);
                textBoxQuery.Text = "";
                Found             = new List <ItemInfo>();

                var cacheLoaded = !force && Index.LoadFromCache();
                if (!cacheLoaded)
                {
                    ReindexWorker(sln);
                }
                else
                {
                    // Lazy reindex
                    var t = new System.Timers.Timer(3000)
                    {
                        AutoReset = false
                    };
                    t.Elapsed += (s, e) => BeginInvoke(new Action(() => ReindexWorker(sln)));
                    t.Start();
                }
            }
            listViewResults.SmallImageList = Index.IconCache.ImageList;
        }