public void Deploy(string email, string password, string[] appIds, DeployChallback callback) { new Action(() => { try { File.Delete(App.AppDataDirectory + settings.GaUploaderCookieFileName); } catch { callback(false, 0, 0, true); return; } var i = 0; for (; i < appIds.Length;) { if (stopped) { return; } var info = new ProcessStartInfo(App.AppDataDirectory + settings.GaPython27FileName); info.Arguments = "-u \"" + App.AppDataDirectory + settings.GaUploaderFileName + "\" " + email + " \"" + password.Replace("\"", "\"\"") + "\" " + appIds[i]; info.RedirectStandardOutput = true; info.RedirectStandardError = true; info.RedirectStandardInput = true; info.UseShellExecute = false; info.CreateNoWindow = true; try { pythonProcess.Kill(); } catch { } pythonProcess = new Process(); callback(false, i, 0); Thread.Sleep(1000); var steps = 17; var step = 0; pythonProcess.ErrorDataReceived += (sender, e) => { step++; if (e.Data != null && e.Data.StartsWith("Completed update of app:")) { i++; } else { callback(false, i, Math.Min(step * 1.0 / steps, 1)); } }; pythonProcess.StartInfo = info; pythonProcess.Start(); pythonProcess.BeginErrorReadLine(); pythonProcess.WaitForExit(); } callback(true, i, 0); try { File.Delete(App.AppDataDirectory + settings.GaUploaderCookieFileName); } catch { } }).BeginInvoke(null, null); }