17 lines
583 B
C#
17 lines
583 B
C#
namespace UCVL.VPNPlus;
|
|
|
|
// The confirmation dialog runs a nested message loop. Shutdown may win while
|
|
// it is open, or while the package is downloading; never launch afterwards.
|
|
internal static class ClientUpdateFlow
|
|
{
|
|
internal static async Task<bool> RunAsync(Func<bool> isCurrent, Func<bool> confirm,
|
|
Func<Task<string>> download, Action<string> launch)
|
|
{
|
|
if (!isCurrent() || !confirm() || !isCurrent()) return false;
|
|
var installer = await download();
|
|
if (!isCurrent()) return false;
|
|
launch(installer);
|
|
return true;
|
|
}
|
|
}
|