From 5fa1a78ddfe370be82d220049c3c01ddcab8e594 Mon Sep 17 00:00:00 2001
From: falcon <9504402@qq.com>
Date: Sat, 2 Apr 2022 09:13:44 +0800
Subject: [PATCH] =?UTF-8?q?=E5=90=8E=E5=8F=B0=E9=95=BF=E6=97=B6=E4=BB=BB?=
=?UTF-8?q?=E5=8A=A1=E9=87=8D=E5=86=99=E5=9C=A8=E9=87=8A=E6=94=BE=E6=97=B6?=
=?UTF-8?q?=E5=80=99=E5=81=9C=E6=AD=A2=E4=BB=BB=E5=8A=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Falcon.SugarApi/BackTask/BackgroundLongTask.cs | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/Falcon.SugarApi/BackTask/BackgroundLongTask.cs b/Falcon.SugarApi/BackTask/BackgroundLongTask.cs
index 2a37089..d90abb5 100644
--- a/Falcon.SugarApi/BackTask/BackgroundLongTask.cs
+++ b/Falcon.SugarApi/BackTask/BackgroundLongTask.cs
@@ -8,7 +8,7 @@ namespace Falcon.SugarApi.BackTask
///
/// 长时间执行的后台任务
///
- public abstract class BackgroundLongTask : BackgroundService
+ public abstract class BackgroundLongTask : BackgroundService, IDisposable
{
///
/// 要执行的任务
@@ -70,5 +70,13 @@ namespace Falcon.SugarApi.BackTask
this.TokenSource.Cancel();
return base.StopAsync(cancellationToken);
}
+
+ ///
+ /// 释放空间,结束任务
+ ///
+ public override void Dispose() {
+ this.TokenSource.Cancel();
+ base.Dispose();
+ }
}
}