From cef51071006f2252c6a9fb54cfcf805f958824be Mon Sep 17 00:00:00 2001 From: integralfx Date: Sat, 2 Mar 2019 11:28:46 +1100 Subject: [PATCH] Bug fixes, changed some stuff --- MemTestHelper/Form1.Designer.cs | 2 +- MemTestHelper/Form1.cs | 32 +++++++++++++++++++++----------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/MemTestHelper/Form1.Designer.cs b/MemTestHelper/Form1.Designer.cs index 49309ee..3337784 100644 --- a/MemTestHelper/Form1.Designer.cs +++ b/MemTestHelper/Form1.Designer.cs @@ -575,7 +575,7 @@ private void InitializeComponent() this.lbl_version.Name = "lbl_version"; this.lbl_version.Size = new System.Drawing.Size(69, 13); this.lbl_version.TabIndex = 0; - this.lbl_version.Text = "Version 1.9.3"; + this.lbl_version.Text = "Version 1.9.4"; // // Form1 // diff --git a/MemTestHelper/Form1.cs b/MemTestHelper/Form1.cs index 48bcfe2..8dd7b49 100644 --- a/MemTestHelper/Form1.cs +++ b/MemTestHelper/Form1.cs @@ -6,6 +6,7 @@ using System.Data; using System.Diagnostics; using System.Drawing; +using System.Globalization; using System.IO; using System.Linq; using System.Management; @@ -686,25 +687,26 @@ private void start_memtests() state.is_finished = false; memtest_states[i] = state; - // wait for processes to start - Thread.Sleep(threads * 50); - - IntPtr hwnd = memtest_states[i].proc.MainWindowHandle; - - if (chk_start_min.Checked) - ShowWindow(hwnd, SW_MINIMIZE); - else + // wait for process to start + while (string.IsNullOrEmpty(state.proc.MainWindowTitle)) { - move_memtests(); - Activate(); + Thread.Sleep(100); + state.proc.Refresh(); } + IntPtr hwnd = state.proc.MainWindowHandle; double ram = Convert.ToDouble(txt_ram.Text) / threads; ControlSetText(hwnd, MEMTEST_EDT_RAM, $"{ram:f2}"); ControlSetText(hwnd, MEMTEST_STATIC_FREE_VER, "Modified version by ∫ntegral#7834"); ControlClick(hwnd, MEMTEST_BTN_START); + + if (chk_start_min.Checked) + ShowWindow(hwnd, SW_MINIMIZE); }); + + if (!chk_start_min.Checked) + move_memtests(); } private void move_memtests() @@ -731,6 +733,7 @@ private void move_memtests() }); } + // only close MemTests started by MemTestHelper private void close_memtests() { Parallel.ForEach(memtest_states, s => @@ -742,6 +745,10 @@ private void close_memtests() }); } + /* + * close all MemTests, regardless of if they were + * started by MemTestHelper + */ private void close_all_memtests() { // remove the .exe @@ -764,7 +771,10 @@ private Tuple get_coverage_info(IntPtr hwnd) // 47.3% Coverage, 0 Errors // ^^^^ - double coverage = Convert.ToDouble(str.Split("%".ToCharArray())[0]); + // some countries use a comma as the decimal point + string coverage_str = str.Split("%".ToCharArray())[0].Replace(',', '.'); + double coverage = 0; + double.TryParse(coverage_str, NumberStyles.Any, CultureInfo.InvariantCulture, out coverage); // 47.3% Coverage, 0 Errors // ^^^^^^^^