From 609eccd75bfd6d54a0e39e277e9ca38a078deed8 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Sun, 15 Jul 2018 22:22:02 +0300 Subject: [PATCH] ex handling --- OWTrack/Form1.cs | 29 ++++++++++++++++++----------- OWTrack/Tracker.cs | 18 +++++++++++++----- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/OWTrack/Form1.cs b/OWTrack/Form1.cs index d231084..1e654ec 100644 --- a/OWTrack/Form1.cs +++ b/OWTrack/Form1.cs @@ -31,17 +31,24 @@ namespace OWTrack private void checkStatus() { - Time.Text = DateTime.Now.ToString("h:mm tt"); - if (tr.owRunning()) - { - status.Text = IS_RUNNING; - status.ForeColor = Color.FromArgb(128, 255, 128); - } - else - { - status.Text = NOT_RUNNING; - status.ForeColor = Color.Red; - } + try + { + Time.Text = DateTime.Now.ToString("h:mm tt"); + if (tr.owRunning()) + { + status.Text = IS_RUNNING; + status.ForeColor = Color.FromArgb(128, 255, 128); + } + else + { + status.Text = NOT_RUNNING; + status.ForeColor = Color.Red; + } + } + catch (Exception e) + { + MessageBox.Show(e.Message); + } } private void button1_Click(object sender, EventArgs e) diff --git a/OWTrack/Tracker.cs b/OWTrack/Tracker.cs index a4baa49..8e89b18 100644 --- a/OWTrack/Tracker.cs +++ b/OWTrack/Tracker.cs @@ -15,12 +15,20 @@ namespace OWTrack { } - + public bool owRunning() - { - bool isRunning = Process.GetProcessesByName("Overwatch") - .FirstOrDefault(p => p.MainModule.FileName.StartsWith(@"D:\Hesham\installed Games\Overwatch")) != default(Process); - return isRunning; + { + try + { + bool isRunning = Process.GetProcessesByName("Overwatch") + .FirstOrDefault(p => p.MainModule.FileName.StartsWith(@"D:\Hesham\installed Games\Overwatch")) != default(Process); + return isRunning; + } + catch (Exception e) + { + Exception ex = new Exception("Error in tracking Overwatch.exe"); + throw ex; + } } public void addWin() { wins++; }