Skip to content

Commit

Permalink
Refactoring: extracted a new private method HandleShutdownClient().
Browse files Browse the repository at this point in the history
  • Loading branch information
xvitaly committed Apr 17, 2024
1 parent 92cc6f3 commit a83dbf6
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions src/srcrepair/FrmMainW.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,27 @@ private bool HandleServiceRepair()
return true;
}

/// <summary>
/// Shuts down the running Steam client and handles possible exceptions.
/// </summary>
private bool HandleShutdownClient()
{
try
{
if (ProcessManager.ProcessTerminate("Steam") != 0)
{
MessageBox.Show(AppStrings.PS_ProcessDetected, Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
catch (Exception Ex)
{
Logger.Error(Ex, DebugStrings.AppDbgExShutdownClient);
MessageBox.Show(AppStrings.PS_ShutdownClientException, Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
return true;
}

/// <summary>
/// Starts Steam client and handles possible exceptions.
/// </summary>
Expand Down Expand Up @@ -1866,10 +1887,7 @@ private void PS_ExecuteNow_Click(object sender, EventArgs e)
{
if (GetRepairSelState() && MessageBox.Show(AppStrings.PS_ExecuteMSG, Properties.Resources.AppName, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
{
if (ProcessManager.ProcessTerminate("Steam") != 0)
{
MessageBox.Show(AppStrings.PS_ProcessDetected, Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
if (!HandleShutdownClient()) { return; }

bool CleanStatus = true;
CleanStatus &= HandleCleanBlobs();
Expand Down

0 comments on commit a83dbf6

Please sign in to comment.