ex handling

This commit is contained in:
HeshamTB 2018-07-15 22:22:02 +03:00
parent 7e71c99a84
commit 609eccd75b
2 changed files with 31 additions and 16 deletions

View File

@ -31,17 +31,24 @@ namespace OWTrack
private void checkStatus() private void checkStatus()
{ {
Time.Text = DateTime.Now.ToString("h:mm tt"); try
if (tr.owRunning()) {
{ Time.Text = DateTime.Now.ToString("h:mm tt");
status.Text = IS_RUNNING; if (tr.owRunning())
status.ForeColor = Color.FromArgb(128, 255, 128); {
} status.Text = IS_RUNNING;
else status.ForeColor = Color.FromArgb(128, 255, 128);
{ }
status.Text = NOT_RUNNING; else
status.ForeColor = Color.Red; {
} status.Text = NOT_RUNNING;
status.ForeColor = Color.Red;
}
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
} }
private void button1_Click(object sender, EventArgs e) private void button1_Click(object sender, EventArgs e)

View File

@ -15,12 +15,20 @@ namespace OWTrack
{ {
} }
public bool owRunning() public bool owRunning()
{ {
bool isRunning = Process.GetProcessesByName("Overwatch") try
.FirstOrDefault(p => p.MainModule.FileName.StartsWith(@"D:\Hesham\installed Games\Overwatch")) != default(Process); {
return isRunning; 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++; } public void addWin() { wins++; }