diff --git a/RGB.NET.Core/RGBSurface.cs b/RGB.NET.Core/RGBSurface.cs
index fa5a038..f990dcd 100644
--- a/RGB.NET.Core/RGBSurface.cs
+++ b/RGB.NET.Core/RGBSurface.cs
@@ -70,23 +70,33 @@ namespace RGB.NET.Core
/// Specifies whether all , (including clean ones) should be updated.
public void Update(bool flushLeds = false)
{
- OnUpdating();
-
- lock (_ledGroups)
+ try
{
- // Update effects
- foreach (ILedGroup ledGroup in _ledGroups)
- ledGroup.UpdateEffects();
+ OnUpdating();
- // Render brushes
- foreach (ILedGroup ledGroup in _ledGroups.OrderBy(x => x.ZIndex))
- Render(ledGroup);
+ lock (_ledGroups)
+ {
+ // Update effects
+ foreach (ILedGroup ledGroup in _ledGroups)
+ try { ledGroup.UpdateEffects(); }
+ catch (Exception ex) { OnException(ex); }
+
+ // Render brushes
+ foreach (ILedGroup ledGroup in _ledGroups.OrderBy(x => x.ZIndex))
+ try { Render(ledGroup); }
+ catch (Exception ex) { OnException(ex); }
+ }
+
+ foreach (IRGBDevice device in Devices)
+ try { device.Update(flushLeds); }
+ catch (Exception ex) { OnException(ex); }
+
+ OnUpdated();
+ }
+ catch (Exception ex)
+ {
+ OnException(ex);
}
-
- foreach (IRGBDevice device in Devices)
- device.Update(flushLeds);
-
- OnUpdated();
}
///
@@ -100,36 +110,28 @@ namespace RGB.NET.Core
if ((brush == null) || !brush.IsEnabled) return;
- try
+ switch (brush.BrushCalculationMode)
{
- switch (brush.BrushCalculationMode)
- {
- case BrushCalculationMode.Relative:
- Rectangle brushRectangle = new Rectangle(leds.Select(x => GetDeviceLedLocation(x)));
- Point offset = new Point(-brushRectangle.Location.X, -brushRectangle.Location.Y);
- brushRectangle.Location.X = 0;
- brushRectangle.Location.Y = 0;
- brush.PerformRender(brushRectangle,
- leds.Select(x => new BrushRenderTarget(x, GetDeviceLedLocation(x, offset))));
- break;
- case BrushCalculationMode.Absolute:
- brush.PerformRender(SurfaceRectangle, leds.Select(x => new BrushRenderTarget(x, GetDeviceLedLocation(x))));
- break;
- default:
- throw new ArgumentException();
- }
-
- brush.UpdateEffects();
- brush.PerformFinalize();
-
- foreach (KeyValuePair renders in brush.RenderedTargets)
- renders.Key.Led.Color = renders.Value;
- }
- // ReSharper disable once CatchAllClause
- catch (Exception ex)
- {
- OnException(ex);
+ case BrushCalculationMode.Relative:
+ Rectangle brushRectangle = new Rectangle(leds.Select(x => GetDeviceLedLocation(x)));
+ Point offset = new Point(-brushRectangle.Location.X, -brushRectangle.Location.Y);
+ brushRectangle.Location.X = 0;
+ brushRectangle.Location.Y = 0;
+ brush.PerformRender(brushRectangle,
+ leds.Select(x => new BrushRenderTarget(x, GetDeviceLedLocation(x, offset))));
+ break;
+ case BrushCalculationMode.Absolute:
+ brush.PerformRender(SurfaceRectangle, leds.Select(x => new BrushRenderTarget(x, GetDeviceLedLocation(x))));
+ break;
+ default:
+ throw new ArgumentException();
}
+
+ brush.UpdateEffects();
+ brush.PerformFinalize();
+
+ foreach (KeyValuePair renders in brush.RenderedTargets)
+ renders.Key.Led.Color = renders.Value;
}
private Rectangle GetDeviceLedLocation(Led led, Point extraOffset = null)