private void waitForFinish() { Console.WriteLine("Waiting for processing to end..."); Boolean finished = false; do { System.Threading.Thread.Sleep(1000); device.refreshFolderContents(servicePlatformFolder); foreach (var item in servicePlatformFolder.Files) { if (item is PortableDeviceFile && item.Name.Equals("mobile-finished")) { Console.WriteLine("Processing finished!"); finished = true; } } } while (!finished); }