This repository has been archived on 2022-08-05. You can view files and clone it, but cannot push or open issues or pull requests.
UpTool2/UpTool2/Task/InstallTask.cs

43 lines
1022 B
C#
Raw Normal View History

2020-04-08 20:57:50 +02:00
using System;
using System.Windows.Forms;
using UpToolLib.DataStructures;
using UpToolLib.Tool;
namespace UpTool2.Task
{
2020-05-16 18:19:43 +02:00
internal class InstallTask : IKnownAppTask
2020-04-08 20:57:50 +02:00
{
private readonly Action? _postInstall;
2020-05-16 18:19:43 +02:00
2020-04-08 20:57:50 +02:00
public InstallTask(App app, Action? postInstall = null)
{
App = app;
_postInstall = postInstall;
}
2020-05-16 18:19:43 +02:00
public override App App { get; }
2020-04-08 20:57:50 +02:00
public override void Run()
{
bool trying = true;
while (trying)
{
#if !DEBUG
try
{
#endif
AppInstall.Install(App, true);
_postInstall?.Invoke();
trying = false;
#if !DEBUG
}
catch (Exception e1)
{
trying = MessageBox.Show(e1.ToString(), "Install failed", MessageBoxButtons.RetryCancel) ==
DialogResult.Retry;
}
#endif
}
}
}
2020-05-16 18:19:43 +02:00
}