public void Run(CommandArgs args) { if (!PluginControl.GetSelectedPreset(out var preset) || preset == null) { return; } var progressForm = new ProgressForm() { Maximum = PluginControl.EndFrame - PluginControl.StartFrame }; using (var writer = progressForm.CreateLogWriter()) { SetOut(writer); try { System.Threading.Tasks.Task.Factory.StartNew(progressForm.ShowDialog); RunWorld(progressForm, preset); } catch (Exception e) { try { Console.WriteLine(Executor.FormatException(e)); } catch { } Console.WriteLine(e); } Console.Out.Flush(); SetOut(new StreamWriter(Console.OpenStandardOutput())); } File.WriteAllText(LogPath, progressForm.LogText); }