From 4cfc5d3505edeb5ae41099ab3f99e32b5847d41e Mon Sep 17 00:00:00 2001 From: GeWuYou <95328647+GeWuYou@users.noreply.github.com> Date: Tue, 27 Jan 2026 22:39:26 +0800 Subject: [PATCH] =?UTF-8?q?refactor(storage):=20=E5=B0=86=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=AD=98=E5=82=A8=E8=AF=BB=E5=8F=96=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E5=BC=82=E6=AD=A5=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 使用 await using 替代 using 确保异步资源正确释放 - 优化文件读取流程以支持异步IO操作 - 提高文件存储组件的异步处理能力 --- GFramework.Game/storage/FileStorage.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GFramework.Game/storage/FileStorage.cs b/GFramework.Game/storage/FileStorage.cs index 3d019b1..fd35bbe 100644 --- a/GFramework.Game/storage/FileStorage.cs +++ b/GFramework.Game/storage/FileStorage.cs @@ -207,7 +207,7 @@ public sealed class FileStorage : IFileStorage // 读取文件内容可以使用异步IO,但要注意锁范围 string content; - using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read)) + await using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read)) using (var sr = new StreamReader(fs, Encoding.UTF8)) { content = await sr.ReadToEndAsync();