From c7118bb566fcbf67516d2c34102872241305d395 Mon Sep 17 00:00:00 2001 From: ZouJin Date: Tue, 15 Aug 2023 20:16:52 +1000 Subject: [PATCH] =?UTF-8?q?=E7=94=9F=E6=88=90=E5=9B=BE=E7=89=87=E9=99=8D?= =?UTF-8?q?=E9=80=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VPet-Simulator.Core/Graph/PNGAnimation.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/VPet-Simulator.Core/Graph/PNGAnimation.cs b/VPet-Simulator.Core/Graph/PNGAnimation.cs index e376cb0..c13a55a 100644 --- a/VPet-Simulator.Core/Graph/PNGAnimation.cs +++ b/VPet-Simulator.Core/Graph/PNGAnimation.cs @@ -61,6 +61,11 @@ namespace VPet_Simulator.Core public string Path; private GraphCore GraphCore; /// + /// 反正一次性生成太多导致闪退 + /// + public static int NowLoading = 0; + private static object nowLoadinglock = new object(); + /// /// 新建 PNG 动画 /// /// 文件夹位置 @@ -163,6 +168,12 @@ namespace VPet_Simulator.Core private void startup(string path, FileInfo[] paths) { + while (NowLoading > 20) + { + Thread.Sleep(100); + } + lock (nowLoadinglock) + NowLoading++; //新方法:加载大图片 //生成大文件加载非常慢,先看看有没有缓存能用 Path = GraphCore.CachePath + $"\\{GraphCore.Resolution}_{Sub.GetHashCode(path)}_{paths.Length}.png"; @@ -206,6 +217,8 @@ namespace VPet_Simulator.Core } //stream = new MemoryStream(File.ReadAllBytes(cp)); IsReady = true; + lock (nowLoadinglock) + NowLoading--; }