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
CreepyCrafter24 c186afa8b4 Stage changes
2020-04-08 20:57:50 +02:00

42 lines
1012 B
C#

using System;
using System.Windows.Forms;
using UpToolLib.DataStructures;
using UpToolLib.Tool;
namespace UpTool2.Task
{
class InstallTask : IKnownAppTask
{
public override App App { get; }
private readonly Action? _postInstall;
public InstallTask(App app, Action? postInstall = null)
{
App = app;
_postInstall = postInstall;
}
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
}
}
}
}