private async Task LoadValueWithRetryAsync() { _updateIsInProgress.Value = true; var exceptions = new List <Exception>(); try { for (var i = 0; i <= _maxRetries; i++) { try { _value = await _factory(_value).ConfigureAwait(false); } catch (Exception e) { exceptions.Add(e); FactoryError?.BeginRaiseEvent(this, e); continue; } ValueCreated?.BeginRaiseEvent(this, _value); return; } MaxRetriesExceeded?.BeginRaiseEvent(this, exceptions); } finally { _updateIsInProgress.Value = false; } }
static void Main(string[] args) { //Application.EnableVisualStyles(); //Application.SetCompatibleTextRenderingDefault(false); //Application.Run(new Form1()); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("es-ES"); System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("es"); // Manejador de excepciones no controladas AppDomain.CurrentDomain.UnhandledException += ExcepcionNoControlada; /// Controlador general de excepciones. Una excepcion no capturada llamará a este evento. Application.ThreadException += Application_ThreadException; Application.ApplicationExit += Application_ApplicationExit; Screen Srn = Screen.PrimaryScreen; _anchoInicio = Srn.Bounds.Width; _altoInicio = Srn.Bounds.Height; //if (Properties.Settings.Default.AdaptarResolucion && (Properties.Settings.Default.AnchoOptimo != _anchoInicio || Properties.Settings.Default.AltoOptimo != _altoInicio)) // CambiarResolucion(); /// Activando skins de DevExpress //DevExpress.UserSkins.OfficeSkins.Register(); //DevExpress.UserSkins.BonusSkins.Register(); //DevExpress.Skins.SkinManager.EnableFormSkins(); //LeerConfig(); ExceptionPolicy.SetExceptionManager(FactoryError.CreateManager()); for (var i = 0; i < args.Length; i++) { if (i > 3) { break; } var v = Convert.ToInt32(args[i]); if (v <= 0) { continue; } switch (i) { case 0: Parametros.IdEmpresa = v; break; case 1: Parametros.IdDelegacion = v; break; case 2: Parametros.IdEjercicio = v; break; case 3: Parametros.IdEmpresaArticulos = v; break; } } _mainForm = new MainForm(); Application.Run(_mainForm); }
private static void MusicNote_Error(object sender, Exception e) { FactoryError?.Invoke(sender, e); }