/// <summary> /// Performs the work of the cleanup. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void bwCleanup_DoWork(object sender, DoWorkEventArgs e) { // Record the start time. this.Invoke(new SetStartAndEndDelegate(setStartAndEnd), new object[] { DateTime.Now, DateTime.MinValue }); Cleaner cleaner = new Cleaner(); // Check for cancellation, then wait to allow the user to read the status. if (bwCleanup.CancellationPending) { e.Cancel = true; bwCleanup.ReportProgress(0); return; } // Empty the Recycle Bin. bwCleanup.ReportProgress(10); Thread.Sleep(500); cleaner.EmptyRecycleBin(); results.Add(new object[] { "Information", "Recycle Bin Emptied", null }); // Check for cancellation, then wait to allow the user to read the status. if (bwCleanup.CancellationPending) { e.Cancel = true; bwCleanup.ReportProgress(0); return; } // Delete Windows Update Download Cache. bwCleanup.ReportProgress(25); Thread.Sleep(500); cleaner.DeleteWindowsUpdateDownloadCache(); results.Add(new object[] { "Information", "Windows Update Download Cache Cleared", null }); // Check for cancellation, then wait to allow the user to read the status. if (bwCleanup.CancellationPending) { e.Cancel = true; bwCleanup.ReportProgress(0); return; } // Delete Windows Prefetch Files. bwCleanup.ReportProgress(35); Thread.Sleep(500); cleaner.DeleteWindowsPrefetchFiles(); results.Add(new object[] { "Information", "Windows Prefetch Cleared", null }); // Check for cancellation, then wait to allow the user to read the status. if (bwCleanup.CancellationPending) { e.Cancel = true; bwCleanup.ReportProgress(0); return; } // Flush the DNS Cache. bwCleanup.ReportProgress(40); Thread.Sleep(500); cleaner.FlushDnsCache(); results.Add(new object[] { "Information", "DNS Cache Flushed", null }); // Check for cancellation, then wait to allow the user to read the status. if (bwCleanup.CancellationPending) { e.Cancel = true; bwCleanup.ReportProgress(0); return; } // Delete Thumbnail Cache. bwCleanup.ReportProgress(44); Thread.Sleep(500); cleaner.DeleteThumbnailCaches(); results.Add(new object[] { "Information", "Thumbnail Caches Cleared", null }); // Check for cancellation, then wait to allow the user to read the status. if (bwCleanup.CancellationPending) { e.Cancel = true; bwCleanup.ReportProgress(0); return; } // Delete Windows Temporary Files. bwCleanup.ReportProgress(50); Thread.Sleep(500); cleaner.DeleteWindowsTemporaryFiles(); results.Add(new object[] { "Information", "Windows Temporary Files Deleted", null }); // Check for cancellation, then wait. if (bwCleanup.CancellationPending) { e.Cancel = true; bwCleanup.ReportProgress(0); return; } // Delete User Temporary Files. bwCleanup.ReportProgress(55); Thread.Sleep(500); cleaner.DeleteUserTemporaryFiles(); results.Add(new object[] { "Information", "User Temporary Files Deleted", null }); // Check for cancellation, then wait. if (bwCleanup.CancellationPending) { e.Cancel = true; bwCleanup.ReportProgress(0); return; } // Perform system health checks. bwCleanup.ReportProgress(60); Thread.Sleep(500); // Check for high memory usage. if (advisor.HasHighMemoryConsumption()) { results.Add(new object[] { "Warning", "High Memory Usage", "high-memory-usage" }); } // Check for insufficient total memory. if (advisor.HasInsufficientMemory()) { results.Add(new object[] { "Warning", "Less than 2GB of Physical Memory", "low-physical-memory" }); } // Check for low hard disk free space. if (advisor.HasHighDiskUsage()) { results.Add(new object[] { "Warning", "Less than 3GB of Free Space on System Disk", "low-free-space" }); } // Check for cancellation, then wait. if (bwCleanup.CancellationPending) { e.Cancel = true; bwCleanup.ReportProgress(0); return; } bwCleanup.ReportProgress(80); Thread.Sleep(500); // Check for old (possibly insecure) Java runtimes. if (advisor.HasOutdatedJava()) { results.Add(new object[] { "Danger", "Outdated Java Runtimes Detected", "java-outdated" }); } // Check for old (possibly insecure) Flash instances. if (advisor.HasOutdatedFlash()) { results.Add(new object[] { "Danger", "Outdated Flash Player Detected", "flash-outdated" }); } // Check for old (possibly insecure) Adobe Reader instances. if (advisor.HasOutdatedReader()) { results.Add(new object[] { "Danger", "Outdated Adobe Reader Detected", "reader-outdated" }); } // Check for cancellation, then wait. if (bwCleanup.CancellationPending) { e.Cancel = true; bwCleanup.ReportProgress(0); return; } bwCleanup.ReportProgress(90); Thread.Sleep(500); // Check for graylisted applications. securityAdvisor.DownloadGraylist(); // Check for cancellation, then wait. if (bwCleanup.CancellationPending) { e.Cancel = true; bwCleanup.ReportProgress(0); return; } List <string> graylistedApplications = securityAdvisor.GetGraylistedApplications(); if (graylistedApplications.Count > 0) { foreach (string application in graylistedApplications) { results.Add(new object[] { "Warning", "Graylisted Application \"" + application + "\" Detected", "graylisted-application-detected" }); } } // Record the end time. this.Invoke(new SetStartAndEndDelegate(setStartAndEnd), new object[] { DateTime.MinValue, DateTime.Now }); // Mark complete, which will show the results. bwCleanup.ReportProgress(100); Thread.Sleep(500); }
/// <summary> /// Performs the work of the cleanup. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void bwCleanup_DoWork(object sender, DoWorkEventArgs e) { // Record the start time. this.Invoke(new SetStartAndEndDelegate(setStartAndEnd), new object[] { DateTime.Now, DateTime.MinValue }); Cleaner cleaner = new Cleaner(); // Check for cancellation, then wait to allow the user to read the status. if (bwCleanup.CancellationPending) { e.Cancel = true; bwCleanup.ReportProgress(0); return; } // Empty the Recycle Bin. bwCleanup.ReportProgress(10); Thread.Sleep(500); cleaner.EmptyRecycleBin(); results.Add(new object[] { "Information", "Recycle Bin Emptied", null }); // Check for cancellation, then wait to allow the user to read the status. if (bwCleanup.CancellationPending) { e.Cancel = true; bwCleanup.ReportProgress(0); return; } // Delete Windows Update Download Cache. bwCleanup.ReportProgress(25); Thread.Sleep(500); cleaner.DeleteWindowsUpdateDownloadCache(); results.Add(new object[] { "Information", "Windows Update Download Cache Cleared", null }); // Check for cancellation, then wait to allow the user to read the status. if (bwCleanup.CancellationPending) { e.Cancel = true; bwCleanup.ReportProgress(0); return; } // Delete Windows Prefetch Files. bwCleanup.ReportProgress(35); Thread.Sleep(500); cleaner.DeleteWindowsPrefetchFiles(); results.Add(new object[] { "Information", "Windows Prefetch Cleared", null }); // Check for cancellation, then wait to allow the user to read the status. if (bwCleanup.CancellationPending) { e.Cancel = true; bwCleanup.ReportProgress(0); return; } // Flush the DNS Cache. bwCleanup.ReportProgress(40); Thread.Sleep(500); cleaner.FlushDnsCache(); results.Add(new object[] { "Information", "DNS Cache Flushed", null }); // Check for cancellation, then wait to allow the user to read the status. if (bwCleanup.CancellationPending) { e.Cancel = true; bwCleanup.ReportProgress(0); return; } // Delete Thumbnail Cache. bwCleanup.ReportProgress(44); Thread.Sleep(500); cleaner.DeleteThumbnailCaches(); results.Add(new object[] { "Information", "Thumbnail Caches Cleared", null }); // Check for cancellation, then wait to allow the user to read the status. if (bwCleanup.CancellationPending) { e.Cancel = true; bwCleanup.ReportProgress(0); return; } // Delete Windows Temporary Files. bwCleanup.ReportProgress(50); Thread.Sleep(500); cleaner.DeleteWindowsTemporaryFiles(); results.Add(new object[] { "Information", "Windows Temporary Files Deleted", null }); // Check for cancellation, then wait. if (bwCleanup.CancellationPending) { e.Cancel = true; bwCleanup.ReportProgress(0); return; } // Delete User Temporary Files. bwCleanup.ReportProgress(55); Thread.Sleep(500); cleaner.DeleteUserTemporaryFiles(); results.Add(new object[] { "Information", "User Temporary Files Deleted", null }); // Check for cancellation, then wait. if (bwCleanup.CancellationPending) { e.Cancel = true; bwCleanup.ReportProgress(0); return; } // Perform system health checks. bwCleanup.ReportProgress(60); Thread.Sleep(500); // Check for high memory usage. if (advisor.HasHighMemoryConsumption()) results.Add(new object[] { "Warning", "High Memory Usage", "high-memory-usage" }); // Check for insufficient total memory. if (advisor.HasInsufficientMemory()) results.Add(new object[] { "Warning", "Less than 2GB of Physical Memory", "low-physical-memory" }); // Check for low hard disk free space. if (advisor.HasHighDiskUsage()) results.Add(new object[] { "Warning", "Less than 3GB of Free Space on System Disk", "low-free-space" }); // Check for cancellation, then wait. if (bwCleanup.CancellationPending) { e.Cancel = true; bwCleanup.ReportProgress(0); return; } bwCleanup.ReportProgress(80); Thread.Sleep(500); // Check for old (possibly insecure) Java runtimes. if (advisor.HasOutdatedJava()) results.Add(new object[] { "Danger", "Outdated Java Runtimes Detected", "java-outdated" }); // Check for old (possibly insecure) Flash instances. if (advisor.HasOutdatedFlash()) results.Add(new object[] { "Danger", "Outdated Flash Player Detected", "flash-outdated" }); // Check for old (possibly insecure) Adobe Reader instances. if (advisor.HasOutdatedReader()) results.Add(new object[] { "Danger", "Outdated Adobe Reader Detected", "reader-outdated" }); // Check for cancellation, then wait. if (bwCleanup.CancellationPending) { e.Cancel = true; bwCleanup.ReportProgress(0); return; } bwCleanup.ReportProgress(90); Thread.Sleep(500); // Check for graylisted applications. securityAdvisor.DownloadGraylist(); // Check for cancellation, then wait. if (bwCleanup.CancellationPending) { e.Cancel = true; bwCleanup.ReportProgress(0); return; } List<string> graylistedApplications = securityAdvisor.GetGraylistedApplications(); if (graylistedApplications.Count > 0) foreach (string application in graylistedApplications) results.Add(new object[] { "Warning", "Graylisted Application \"" + application + "\" Detected", "graylisted-application-detected" }); // Record the end time. this.Invoke(new SetStartAndEndDelegate(setStartAndEnd), new object[] { DateTime.MinValue, DateTime.Now }); // Mark complete, which will show the results. bwCleanup.ReportProgress(100); Thread.Sleep(500); }