Skip to content

Commit

Permalink
Now it is not possible for user to use ALT+F4 to close the updater wh…
Browse files Browse the repository at this point in the history
…en mandatory mode is Forced or ForcedDownload.
  • Loading branch information
ravibpatel committed Aug 4, 2020
1 parent f07d5da commit a6b7f74
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
16 changes: 9 additions & 7 deletions AutoUpdater.NET/DownloadUpdateDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ private void WebClientOnDownloadFileCompleted(object sender, AsyncCompletedEvent
}
finally
{
DialogResult = _webClient == null ? DialogResult.Cancel : DialogResult.OK;
FormClosing -= DownloadUpdateDialog_FormClosing;
Close();
}
}
Expand Down Expand Up @@ -255,19 +257,19 @@ private static void CompareChecksum(string fileName, CheckSum checksum)

private void DownloadUpdateDialog_FormClosing(object sender, FormClosingEventArgs e)
{
if (_webClient == null)
if (AutoUpdater.Mandatory && AutoUpdater.UpdateMode == Mode.ForcedDownload)
{
DialogResult = DialogResult.Cancel;
if (e.CloseReason == CloseReason.UserClosing)
{
e.Cancel = true;
return;
}
}
else if (_webClient.IsBusy)
if (_webClient != null && _webClient.IsBusy)
{
_webClient.CancelAsync();
DialogResult = DialogResult.Cancel;
}
else
{
DialogResult = DialogResult.OK;
}
}
}
}
1 change: 1 addition & 0 deletions AutoUpdater.NET/UpdateForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions AutoUpdater.NET/UpdateForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,5 +178,13 @@ private void UpdateForm_FormClosed(object sender, FormClosedEventArgs e)
{
AutoUpdater.Running = false;
}

private void UpdateForm_FormClosing(object sender, FormClosingEventArgs e)
{
if (AutoUpdater.Mandatory && AutoUpdater.UpdateMode == Mode.Forced)
{
e.Cancel = e.CloseReason == CloseReason.UserClosing;
}
}
}
}

0 comments on commit a6b7f74

Please sign in to comment.