Skip to content

Commit

Permalink
fix(banner): banner crashing randomnly
Browse files Browse the repository at this point in the history
Fixes SOUNDSWITCH-1PF
  • Loading branch information
Belphemur committed Jun 1, 2024
1 parent a827eca commit 8ffa6d9
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions SoundSwitch/Framework/Banner/BannerForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
********************************************************************/

using System;
using System.ComponentModel;
using System.Drawing;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -222,18 +223,32 @@ private void TriggerHidingDisposal()
/// </summary>
private async void FadeOut()
{
while (Opacity > 0.0)
try
{
await Task.Delay(50);

if (!_hiding)
break;
Opacity -= 0.05;
while (Opacity > 0.0)
{
await Task.Delay(50);

if (!_hiding)
break;
Opacity -= 0.05;
}

if (_hiding)
{
Dispose();
}
}

if (_hiding)
catch (Win32Exception)
{
Dispose();
try
{
Dispose();
}
catch (Exception)
{
//Ignored
}
}
}
}
Expand Down

0 comments on commit 8ffa6d9

Please sign in to comment.