mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-26 22:10:21 +00:00
re-add lock to avoid race condition
enough pls
This commit is contained in:
parent
aa08ed0c24
commit
1313d84d5d
1 changed files with 13 additions and 3 deletions
|
@ -19,6 +19,7 @@ namespace PKHeX.WinForms.Controls
|
|||
private readonly Image ExtraLayer;
|
||||
private Image[] GlowCache;
|
||||
public Image OriginalBackground;
|
||||
private readonly object Lock = new object();
|
||||
|
||||
private PictureBox pb;
|
||||
private int GlowInterval;
|
||||
|
@ -34,11 +35,15 @@ namespace PKHeX.WinForms.Controls
|
|||
{
|
||||
if (pb == null || !Enabled)
|
||||
return;
|
||||
Enabled = false;
|
||||
|
||||
lock (Lock)
|
||||
{
|
||||
Enabled = false;
|
||||
pb.BackgroundImage = OriginalBackground;
|
||||
}
|
||||
|
||||
// reset logic
|
||||
GlowCounter = 0;
|
||||
pb.BackgroundImage = OriginalBackground;
|
||||
for (int i = 0; i < GlowCache.Length; i++)
|
||||
GlowCache[i] = null;
|
||||
}
|
||||
|
@ -61,7 +66,12 @@ namespace PKHeX.WinForms.Controls
|
|||
return; // timer canceled, was waiting to proceed
|
||||
GlowCounter = (GlowCounter + 1) % (GlowInterval * 2); // loop backwards
|
||||
int frameIndex = GlowCounter >= GlowInterval ? (GlowInterval * 2) - GlowCounter : GlowCounter;
|
||||
pb.BackgroundImage = GetFrame(frameIndex);
|
||||
|
||||
lock (Lock)
|
||||
{
|
||||
if (Enabled)
|
||||
pb.BackgroundImage = GetFrame(frameIndex);
|
||||
}
|
||||
}
|
||||
|
||||
private Image GetFrame(int frameIndex)
|
||||
|
|
Loading…
Reference in a new issue