diff --git a/src/c#/GeneralUpdate.ClientCore/GeneralClientBootstrap.cs b/src/c#/GeneralUpdate.ClientCore/GeneralClientBootstrap.cs index 9227e626dcb54fd725cd9b100baee2da23516516..b20053c2457a0719527e89443d948428605f3036 100644 --- a/src/c#/GeneralUpdate.ClientCore/GeneralClientBootstrap.cs +++ b/src/c#/GeneralUpdate.ClientCore/GeneralClientBootstrap.cs @@ -54,8 +54,7 @@ namespace GeneralUpdate.ClientCore private async Task BaseLaunch() { - //bool isSuccess = await ExecuteCustomOptions(); - //if (!isSuccess) return this; + await ExecuteCustomOptions(); var versionService = new VersionService(); var mainResp = await versionService.ValidationVersion(Packet.MainUpdateUrl); var upgradeResp = await versionService.ValidationVersion(Packet.UpdateUrl); @@ -161,11 +160,11 @@ namespace GeneralUpdate.ClientCore /// /// /// - public GeneralClientBootstrap AddCustomOption(Func func) + public GeneralClientBootstrap AddCustomOption(List> funcs) { - if(func == null) throw new ArgumentNullException(nameof(func)); - _customOptions.Add(func); - return this; + if (funcs == null || !funcs.Any()) throw new ArgumentNullException(nameof(funcs)); + _customOptions.AddRange(funcs); + return this; } /// @@ -175,10 +174,10 @@ namespace GeneralUpdate.ClientCore /// /// /// - public GeneralClientBootstrap AddCustomOption(Func> func) + public GeneralClientBootstrap AddCustomOption(List>> funcs) { - if (func == null) throw new ArgumentNullException(nameof(func)); - _customTaskOptions.Add(func); + if (funcs == null || !funcs.Any()) throw new ArgumentNullException(nameof(funcs)); + _customTaskOptions.AddRange(funcs); return this; } @@ -223,24 +222,26 @@ namespace GeneralUpdate.ClientCore /// Performs all injected custom operations. /// /// - private async Task ExecuteCustomOptions() + private async Task ExecuteCustomOptions() { - if (_customOptions.Any()) - { - _customOptions.ForEach(option => option.Invoke()); - return true; - } - if (_customTaskOptions.Any()) { foreach (var option in _customTaskOptions) { - await option.Invoke(); + var isSuccess = await option.Invoke(); + if (!isSuccess) + Core.Events.EventManager.Instance.Dispatch>(this, new Core.Events.CommonArgs.ExceptionEventArgs($"{nameof(option)}Execution failure!")); + } + } + else if (_customOptions.Any()) + { + foreach (var option in _customOptions) + { + var isSuccess = option.Invoke(); + if (!isSuccess) + Core.Events.EventManager.Instance.Dispatch>(this, new Core.Events.CommonArgs.ExceptionEventArgs($"{nameof(option)}Execution failure!")); } - return true; } - - return true; } #endregion Private Methods diff --git a/src/c#/GeneralUpdate.Core/Events/CommonArgs/ExceptionEventArgs.cs b/src/c#/GeneralUpdate.Core/Events/CommonArgs/ExceptionEventArgs.cs index 919fae2ed19afef7358dbbec3cc5d2ee7f170557..eb845184323855576d38073e9e665bbfd7e233ad 100644 --- a/src/c#/GeneralUpdate.Core/Events/CommonArgs/ExceptionEventArgs.cs +++ b/src/c#/GeneralUpdate.Core/Events/CommonArgs/ExceptionEventArgs.cs @@ -11,6 +11,8 @@ namespace GeneralUpdate.Core.Events.CommonArgs _exception = exception; } + public ExceptionEventArgs(string mesage)=> _exception = new Exception(mesage); + public Exception Exception => _exception; } } \ No newline at end of file diff --git a/src/c#/GeneralUpdate.Core/Strategys/PlatformWindows/WindowsStrategy.cs b/src/c#/GeneralUpdate.Core/Strategys/PlatformWindows/WindowsStrategy.cs index 864a67e6729c479439d87127177ea1b13043359f..228a1fcde8c651bc8daf97fd42e952b9e5fc7ea0 100644 --- a/src/c#/GeneralUpdate.Core/Strategys/PlatformWindows/WindowsStrategy.cs +++ b/src/c#/GeneralUpdate.Core/Strategys/PlatformWindows/WindowsStrategy.cs @@ -146,7 +146,7 @@ namespace GeneralUpdate.Core.Strategys.PlatformWindows var startTime = DateTime.UtcNow; while (DateTime.UtcNow - startTime < timeout) { - Thread.Sleep(10 * 1000); + Thread.Sleep(2 * 1000); if (!process.HasExited) { callbackAction?.Invoke(applicationPath);