Skip to content

Commit

Permalink
Fixes, Make Kill Not Responding Pref Apply
Browse files Browse the repository at this point in the history
  • Loading branch information
MistressPlague committed Jun 13, 2021
1 parent 38cacee commit 9fe0883
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions Auto Restart Process/Auto Restart Process/Auto Restart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ private void textBox1_TextChanged(object sender, EventArgs e)

private void checkBox2_CheckedChanged(object sender, EventArgs e)
{
RegistryKey rk = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
var rk = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);

if (rk != null)
{
Expand Down Expand Up @@ -345,11 +345,11 @@ private void RestartWorker_DoWork(object sender, System.ComponentModel.DoWorkEve

Log("Restarting!");

ProcessStartInfo Info = new ProcessStartInfo
var Info = new ProcessStartInfo
{
FileName = textBox1.Text ?? "",
WorkingDirectory = Path.GetDirectoryName(textBox1.Text) ?? Environment.CurrentDirectory,
Arguments = textBox2.Text.Replace("%APPDIR%", Path.GetDirectoryName(textBox1.Text) ?? Environment.CurrentDirectory).Replace("%TIME%", DateTime.Now.ToString("dd MM ss tt")),
Arguments = textBox2.Text.Replace("%APPDIR%", Path.GetDirectoryName(textBox1.Text) ?? Environment.CurrentDirectory).Replace("%TIME%", DateTime.Now.ToString("dd MM yyyy - hh mm ss tt")),
CreateNoWindow = checkBox3.Checked,
WindowStyle = (ProcessWindowStyle)comboBox1.SelectedIndex
};
Expand All @@ -361,25 +361,31 @@ private void RestartWorker_DoWork(object sender, System.ComponentModel.DoWorkEve
AlreadyStarted:
while (Proc != null && !Proc.HasExited)
{
if (HungTimePassed.ElapsedMilliseconds >= numericUpDown2.Value)
if (NotRespondingPref.Checked)
{
HungTimePassed.Reset();
Proc.Kill();
break;
if (HungTimePassed.ElapsedMilliseconds >= numericUpDown2.Value)
{
HungTimePassed.Reset();
Proc.Kill();
break;
}
}

if (Proc.HasExited)
{
break;
}

if (!Proc.Responding)
{
HungTimePassed.Start();
}
else
if (NotRespondingPref.Checked)
{
HungTimePassed.Reset();
if (!Proc.Responding)
{
HungTimePassed.Start();
}
else
{
HungTimePassed.Reset();
}
}
}

Expand All @@ -389,7 +395,9 @@ private void RestartWorker_DoWork(object sender, System.ComponentModel.DoWorkEve

if (checkBox1.Checked)
{
label5.Text = "Restart Count: " + RestartCount++;
RestartCount++;

label5.Text = "Restart Count: " + RestartCount;
}
}
}
Expand Down

0 comments on commit 9fe0883

Please sign in to comment.