From 552e29596026ed971c36afb411e840172e64ec42 Mon Sep 17 00:00:00 2001 From: emkael Date: Sun, 27 Oct 2019 16:48:26 +0100 Subject: Optional dump/send on program exit, according to a dialog answer --- spedytor/Form1.cs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/spedytor/Form1.cs b/spedytor/Form1.cs index e7ccd26..093455b 100644 --- a/spedytor/Form1.cs +++ b/spedytor/Form1.cs @@ -26,6 +26,13 @@ namespace spedytor private void bExit_Click(object sender, EventArgs e) { + if (this.selectedDBs.Count > 0) + { + if (MessageBox.Show("Czy chcesz zrzucić/wysłać bazy przed zakończeniem działania programu?", "Spedytor - wyjście", MessageBoxButtons.YesNo) == DialogResult.Yes) + { + tInterval_Tick(null, null); + } + } Logger.getLogger(this.tbLog, LOG_FILENAME).cleanup(); this.Dispose(); } @@ -84,11 +91,12 @@ namespace spedytor return null; } - private void invokeSave(string filePath, string dbName, bool enableControls = false) + private Thread invokeSave(string filePath, string dbName, bool enableControls = false) { Thread t = new Thread(() => this.saveFile(filePath, dbName, this.getBucketID(), enableControls)); t.IsBackground = true; t.Start(); + return t; } private string getDirectory() @@ -201,10 +209,18 @@ namespace spedytor } if (this.repeatFilePath.Length > 0) { + List threadList = new List(); foreach (string dbName in this.selectedDBs) { string filePath = Path.Combine(this.repeatFilePath, dbName + DateTime.Now.ToString("-yyyyMMdd-HHmmss") + ".sql"); - this.invokeSave(filePath, dbName, false); + threadList.Add(this.invokeSave(filePath, dbName, false)); + } + if (e == null) // programmatic invoke, not actual button click + { + foreach (Thread t in threadList) + { + t.Join(); + } } } else -- cgit v1.2.3