From 7de18bd1ad0990306ce44c3ea9a5d3c3d59c942b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E4=BC=9F?= <421281095@qq.com> Date: Fri, 4 Jul 2025 15:33:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AE=9E=E6=97=B6=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.xaml.cs | 13 ++++++++++--- Services/MinioService.cs | 3 ++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/App.xaml.cs b/App.xaml.cs index 78bbc01..401b0cf 100644 --- a/App.xaml.cs +++ b/App.xaml.cs @@ -201,9 +201,16 @@ namespace HeBianGu.App.Disk setting.TaskCount); syncModel.SyncProgressText = "同步完成"; }); - - minioService.RealTimeListen(bucketName, setting.SyncDir, - cancellationToken: cancelToken.Token); + Task.Run(async () => + { + await minioService.RealTimeListen(bucketName, setting.SyncDir, ( fileName) => + { + //添加同步信息 + syncModel.SyncProgressText = $"实时同步中: {fileName}"; + }, + cancellationToken: cancelToken.Token); + syncModel.SyncProgressText = $"实时同步完成"; + }); notRun = false; } catch (OperationCanceledException) diff --git a/Services/MinioService.cs b/Services/MinioService.cs index 2754853..d53ef0e 100644 --- a/Services/MinioService.cs +++ b/Services/MinioService.cs @@ -347,7 +347,7 @@ namespace Hopetry.Services } // 实时监听方法 - public async Task RealTimeListen(string bucketName, string localDir, string prefix = "", string suffix = "", + public async Task RealTimeListen(string bucketName, string localDir,Action action, string prefix = "", string suffix = "", CancellationToken cancellationToken = default) { Console.WriteLine("开启实时监听"); @@ -373,6 +373,7 @@ namespace Hopetry.Services }, async (item, _) => { + action(item.objectKey); await DownLoadObject(item.bucketName, item.objectKey, item.localDir, item.objectETag); }); });