Example #1
0
        public static void GenerateMisingInformation(List <ApplicationUninstallerEntry> entries,
                                                     InfoAdderManager infoAdder, List <Guid> msiProducts, bool skipRunLast,
                                                     ListGenerationProgress.ListGenerationCallback progressCallback)
        {
            void WorkLogic(ApplicationUninstallerEntry entry, object state)
            {
                infoAdder.AddMissingInformation(entry, skipRunLast);
                if (msiProducts != null)
                {
                    entry.IsValid = FactoryTools.CheckIsValid(entry, msiProducts);
                }
            }

            var workSpreader = new ThreadedWorkSpreader <ApplicationUninstallerEntry, object>(MaxThreadsPerDrive,
                                                                                              WorkLogic, list => null, entry => entry.DisplayName ?? entry.RatingId ?? string.Empty);

            var cDrive       = new DirectoryInfo(Environment.SystemDirectory).Root;
            var dividedItems = SplitByPhysicalDrives(entries, entry =>
            {
                var loc = entry.InstallLocation ?? entry.UninstallerLocation;
                if (!string.IsNullOrEmpty(loc))
                {
                    try
                    {
                        return(new DirectoryInfo(loc));
                    }
                    catch (SystemException ex)
                    {
                        Console.WriteLine(ex);
                    }
                }
                return(cDrive);
            });

            workSpreader.Start(dividedItems, progressCallback);
            workSpreader.Join();
        }