using System; using System.Collections.Generic; using System.Linq; using System.Diagnostics; using System.Threading; namespace PicasaCleanupAgent { /// /// Workaround for a bug in Google's Picasa Photo Viewer /// that results in PicasaPhotoViewer.exe remaining in /// memory after opening images on a network drive. /// static class Program { static void Main(string[] args) { while (true) { var picasaProcesses = (from p in Process.GetProcessesByName("PicasaPhotoViewer") where p.MainWindowHandle == IntPtr.Zero && !p.HasExited select p); foreach (var process in picasaProcesses) { process.WaitForInputIdle(); if (process.MainWindowHandle == IntPtr.Zero) { process.Kill(); process.WaitForExit(); } } Thread.Sleep(1000); } } } }