Example #1
0
        void SearchNewThread(object o)
        {
            AppCulture.InitializeCulture();
            try {
                var searchMsg = SearchResult.CreateMessage(filterSearcherOptions.Context, dnSpy_Resources.Searching, TextTokenKind.Text, true);
                SearchingResult = searchMsg;
                AddSearchResultNoCheck(searchMsg);
                var opts = new ParallelOptions {
                    CancellationToken      = cancellationTokenSource.Token,
                    MaxDegreeOfParallelism = Environment.ProcessorCount,
                };

                if (o is IDnSpyFileNode[])
                {
                    Parallel.ForEach((IDnSpyFileNode[])o, opts, node => {
                        AppCulture.InitializeCulture();
                        cancellationTokenSource.Token.ThrowIfCancellationRequested();
                        var searcher = new FilterSearcher(filterSearcherOptions);
                        searcher.SearchAssemblies(new IDnSpyFileNode[] { node });
                    });
                }
                else if (o is SearchTypeInfo[])
                {
                    Parallel.ForEach((SearchTypeInfo[])o, opts, info => {
                        AppCulture.InitializeCulture();
                        cancellationTokenSource.Token.ThrowIfCancellationRequested();
                        var searcher = new FilterSearcher(filterSearcherOptions);
                        searcher.SearchTypes(new SearchTypeInfo[] { info });
                    });
                }
                else
                {
                    throw new InvalidOperationException();
                }
            }
            catch (AggregateException ex) {
                if (ex.InnerExceptions.Any(a => a is TooManyResultsException))
                {
                    TooManyResults = true;
                }
                else
                {
                    throw;
                }
            }
            catch (TooManyResultsException) {
                TooManyResults = true;
            }
            finally {
                filterSearcherOptions.Dispatcher.BeginInvoke(DISPATCHER_PRIO, new Action(SearchCompleted));
            }
        }
Example #2
0
        void SearchNewThread(object o)
        {
            AppCulture.InitializeCulture();
            var files = (IDnSpyFileNode[])o;

            try {
                var searchMsg = SearchResult.CreateMessage(filterSearcherOptions.Context, dnSpy_Resources.Searching, TextTokenKind.Text, true);
                SearchingResult = searchMsg;
                AddSearchResultNoCheck(searchMsg);
                var searcher = new FilterSearcher(filterSearcherOptions);
                searcher.SearchAssemblies(files);
            }
            catch (TooManyResultsException) {
                TooManyResults = true;
            }
            finally {
                filterSearcherOptions.Dispatcher.BeginInvoke(DISPATCHER_PRIO, new Action(SearchCompleted));
            }
        }
Example #3
0
        void SearchNewThread(object o)
        {
            AppCulture.InitializeCulture();
            try {
                var searchMsg = SearchResult.CreateMessage(filterSearcherOptions.Context, dnSpy_Resources.Searching, TextTokenKind.Text, true);
                SearchingResult = searchMsg;
                AddSearchResultNoCheck(searchMsg);
                var opts = new ParallelOptions {
                    CancellationToken = cancellationTokenSource.Token,
                    MaxDegreeOfParallelism = Environment.ProcessorCount,
                };

                if (o is IDnSpyFileNode[]) {
                    Parallel.ForEach((IDnSpyFileNode[])o, opts, node => {
                        AppCulture.InitializeCulture();
                        cancellationTokenSource.Token.ThrowIfCancellationRequested();
                        var searcher = new FilterSearcher(filterSearcherOptions);
                        searcher.SearchAssemblies(new IDnSpyFileNode[] { node });
                    });
                }
                else if (o is SearchTypeInfo[]) {
                    Parallel.ForEach((SearchTypeInfo[])o, opts, info => {
                        AppCulture.InitializeCulture();
                        cancellationTokenSource.Token.ThrowIfCancellationRequested();
                        var searcher = new FilterSearcher(filterSearcherOptions);
                        searcher.SearchTypes(new SearchTypeInfo[] { info });
                    });
                }
                else
                    throw new InvalidOperationException();
            }
            catch (AggregateException ex) {
                if (ex.InnerExceptions.Any(a => a is TooManyResultsException))
                    TooManyResults = true;
                else
                    throw;
            }
            catch (TooManyResultsException) {
                TooManyResults = true;
            }
            finally {
                filterSearcherOptions.Dispatcher.BeginInvoke(DISPATCHER_PRIO, new Action(SearchCompleted));
            }
        }
Example #4
0
 void SearchNewThread(object o)
 {
     AppCulture.InitializeCulture();
     var files = (IDnSpyFileNode[])o;
     try {
         var searchMsg = SearchResult.CreateMessage(filterSearcherOptions.Context, dnSpy_Resources.Searching, TextTokenKind.Text, true);
         SearchingResult = searchMsg;
         AddSearchResultNoCheck(searchMsg);
         var searcher = new FilterSearcher(filterSearcherOptions);
         searcher.SearchAssemblies(files);
     }
     catch (TooManyResultsException) {
         TooManyResults = true;
     }
     finally {
         filterSearcherOptions.Dispatcher.BeginInvoke(DISPATCHER_PRIO, new Action(SearchCompleted));
     }
 }